package com.mvd.app.activity;


import android.Manifest;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.jph.takephoto.app.TakePhoto;
import com.jph.takephoto.app.TakePhotoActivity;
import com.jph.takephoto.model.TImage;
import com.jph.takephoto.model.TResult;
import com.jph.takephoto.model.TakePhotoOptions;
import com.kongzue.dialog.util.DialogSettings;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.mvd.app.R;
import com.mvd.app.ac2019.VideoRecorderActivity;
import com.mvd.app.ac2021.activitys.ErrorMsgActivity;
import com.mvd.app.ac2021.activitys.WaiJianItemActivity;
import com.mvd.app.adapter.ContentAdapter2;
import com.mvd.app.api.ApiConfig;
import com.mvd.app.application.BaseApplication;
import com.mvd.app.commons.CommonUtils;
import com.mvd.app.commons.DateUtil;
import com.mvd.app.commons.JsonUtil;
import com.mvd.app.commons.PDALogUtils;
import com.mvd.app.commons.SharedPreferencesUtils;
import com.mvd.app.commons.SystemUtil;
import com.mvd.app.commons.Utils;
import com.mvd.app.commons.UtilsLog;
import com.mvd.app.model.CarItemEndModel;
import com.mvd.app.model.CarsInforModel;
import com.mvd.app.model.CheckItemModel;
import com.mvd.app.model.CodeListModel;
import com.mvd.app.model.Item_2Model;
import com.mvd.app.model.ItemsModel;
import com.mvd.app.model.MyChoiceModel;
import com.mvd.app.model.OtherWaiJianPhotoModel;
import com.mvd.app.model.OutPhotoItem;
import com.mvd.app.model.PhotoTypeModel;
import com.mvd.app.model.StationInforModel;
import com.mvd.app.model.TypeModel;
import com.mvd.app.model.UpdateCarStatusModel;
import com.mvd.app.model.VideoModel;
import com.mvd.app.model.WaiJainDataModel;
import com.mvd.app.model.WaiJianAddRecordModel;
import com.mvd.app.model.WaiJianItemModel;
import com.orhanobut.logger.Logger;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.iwgang.countuptime.CountupView;
import pub.devrel.easypermissions.EasyPermissions;
import top.zibin.luban.Luban;
import top.zibin.luban.OnCompressListener;

import static com.mvd.app.application.BaseApplication.WAIJIAN_PHOTO_PREVIEW_LISTS;
import static com.mvd.app.application.BaseApplication.checkItemModelList;
import static com.mvd.app.application.BaseApplication.myChoiceModelList;
import static com.mvd.app.application.BaseApplication.mycar_checkItemlList;
import static com.mvd.app.application.BaseApplication.waiJianPhoto_buhege_List;

/**
 *
 */
//外检拍照
public class WaiJianPhotoActivity extends TakePhotoActivity implements AdapterView.OnItemClickListener,
        ApiConfig, EasyPermissions.PermissionCallbacks {
    //region
    @BindView(R.id.ac_waijian_txt_zuoqianfang_45)
    TextView acWaijianTxtZuoqianfang45;
    @BindView(R.id.ac_waijian_btn_zuoqianfang_45)
    Button acWaijianBtnZuoqianfang45;
    @BindView(R.id.ac_waijian_txt_youhoufang_45)
    TextView acWaijianTxtYouhoufang45;
    @BindView(R.id.ac_waijian_btn_youhoufang_45)
    Button acWaijianBtnYouhoufang45;
    @BindView(R.id.ac_waijian_txt_shibiedaima)
    TextView acWaijianTxtShibiedaima;
    @BindView(R.id.ac_waijian_btn_shibiedaima)
    Button acWaijianBtnShibiedaima;
    @BindView(R.id.ac_waijian_txt_anquandai)
    TextView acWaijianTxtAnquandai;
    @BindView(R.id.ac_waijian_btn_anquandai)
    Button acWaijianBtnAnquandai;
    @BindView(R.id.ac_waijian_lay_anquandai)
    LinearLayout acWaijianLayAnquandai;
    @BindView(R.id.ac_waijian_txt_xingshi_jilu)
    TextView acWaijianTxtXingshiJilu;
    @BindView(R.id.ac_waijian_btn_xingshi_jilu)
    Button acWaijianBtnXingshiJilu;
    @BindView(R.id.ac_waijian_xingshi_jilu)
    LinearLayout acWaijianXingshiJilu;
    @BindView(R.id.ac_waijian_txt_miehuoqi)
    TextView acWaijianTxtMiehuoqi;
    @BindView(R.id.ac_waijian_btn_miehuoqi)
    Button acWaijianBtnMiehuoqi;
    @BindView(R.id.ac_waijian_miehuoqi)
    LinearLayout acWaijianMiehuoqi;
    @BindView(R.id.ac_waijian_txt_chexiangneibu)
    TextView acWaijianTxtChexiangneibu;
    @BindView(R.id.ac_waijian_btn_chexiangneibu)
    Button acWaijianBtnChexiangneibu;
    @BindView(R.id.ac_waijian_chexiangneibu)
    LinearLayout acWaijianChexiangneibu;
    @BindView(R.id.ac_waijian_txt_cheliang_zhenghoufang)
    TextView acWaijianTxtCheliangZhenghoufang;
    @BindView(R.id.ac_waijian_btn_cheliang_zhenghoufang)
    Button acWaijianBtnCheliangZhenghoufang;
    @BindView(R.id.ac_waijian_cheliang_zhenghoufang)
    LinearLayout acWaijianCheliangZhenghoufang;
    @BindView(R.id.ac_waijian_txt_xiaochebiaopai)
    TextView acWaijianTxtXiaochebiaopai;
    @BindView(R.id.ac_waijian_btn_xiaochebiaopai)
    Button acWaijianBtnXiaochebiaopai;
    //    @BindView(R.id.ac_waijian_xiaochebiaopai)
//    LinearLayout acWaijianXiaochebiaopai;
//    @BindView(R.id.ac_waijian_txt_xiaoche_biaozhideng)
//    TextView acWaijianTxtXiaocheBiaozhideng;
    @BindView(R.id.ac_waijian_btn_xiaoche_biaozhideng)
    Button acWaijianBtnXiaocheBiaozhideng;
    @BindView(R.id.ac_waijian_xiaoche_biaozhideng)
    LinearLayout acWaijianXiaocheBiaozhideng;
    @BindView(R.id.ac_waijian_txt_xiaoche_tingche_zhishipai)
    TextView acWaijianTxtXiaocheTingcheZhishipai;
    @BindView(R.id.ac_waijian_btn_xiaoche_tingche_zhishipai)
    Button acWaijianBtnXiaocheTingcheZhishipai;
    @BindView(R.id.ac_waijian_xiaoche_tingche_zhishipai)
    LinearLayout acWaijianXiaocheTingcheZhishipai;
    @BindView(R.id.ac_waijian_btn_wancheng)
    Button acWaijianBtnWancheng;

    @BindView(R.id.ac_waijian_txt_caozong_fuzhu)
    TextView acWaijianTxtCaozongFuzhu;
    @BindView(R.id.ac_waijian_btn_caozong_fuzhu)
    Button acWaijianBtnCaozongFuzhu;
    @BindView(R.id.ac_waijian_caozong_fuzhu_fuzhu)
    LinearLayout acWaijianCaozongFuzhu;
    @BindView(R.id.ac_waijian_txt_fadongjihao)
    TextView acWaijianTxtFadongjihao;
    @BindView(R.id.ac_waijian_btn_fadongjihao)
    Button acWaijianBtnFadongjihao;
    @BindView(R.id.ac_waijian_fadongjihao)
    LinearLayout acWaijianFadongjihao;
    @BindView(R.id.ac_waijian_txt_fadongjicang)
    TextView acWaijianTxtFadongjicang;
    @BindView(R.id.ac_waijian_btn_fadongjicang)
    Button acWaijianBtnFadongjicang;
    @BindView(R.id.ac_waijian_fadongjicang)
    LinearLayout acWaijianFadongjicang;
    @BindView(R.id.ac_waijian_txt_yingjichui)
    TextView acWaijianTxtYingjichui;
    @BindView(R.id.ac_waijian_btn_yingjichui)
    Button acWaijianBtnYingjichui;
    @BindView(R.id.ac_waijian_yingjichui)
    LinearLayout acWaijianYingjichui;
    @BindView(R.id.ac_waijian_txt_jijiuxiang)
    TextView acWaijianTxtJijiuxiang;
    @BindView(R.id.ac_waijian_btn_jijiuxiang)
    Button acWaijianBtnJijiuxiang;
    @BindView(R.id.ac_waijian_jijiuxiang)
    LinearLayout acWaijianJijiuxiang;
    @BindView(R.id.ac_waijian_txt_fangbaosi)
    TextView acWaijianTxtFangbaosi;
    @BindView(R.id.ac_waijian_btn_fangbaosi)
    Button acWaijianBtnFangbaosi;
    @BindView(R.id.ac_waijian_fangbaosi)
    LinearLayout acWaijianFangbaosi;
    @BindView(R.id.ac_waijian_txt_fuzhuzhidong)
    TextView acWaijianTxtFuzhuzhidong;
    @BindView(R.id.ac_waijian_btn_fuzhuzhidong)
    Button acWaijianBtnFuzhuzhidong;
    @BindView(R.id.ac_waijian_fuzhuzhidong)
    LinearLayout acWaijianFuzhuzhidong;
    @BindView(R.id.ac_waijian_txt_jinji_qieduan)
    TextView acWaijianTxtJinjiQieduan;
    @BindView(R.id.ac_waijian_btn_jinji_qieduan)
    Button acWaijianBtnJinjiQieduan;
    @BindView(R.id.ac_waijian_jinji_qieduan)
    LinearLayout acWaijianJinjiQieduan;
    @BindView(R.id.ac_waijian_txt_shoudong_jixie)
    TextView acWaijianTxtShoudongJixie;
    @BindView(R.id.ac_waijian_btn_shoudong_jixie)
    Button acWaijianBtnShoudongJixie;
    @BindView(R.id.ac_waijian_shoudong_jixie)
    LinearLayout acWaijianShoudongJixie;
    @BindView(R.id.ac_waijian_txt_fu_zhidong_taban)
    TextView acWaijianTxtFuZhidongTaban;
    @BindView(R.id.ac_waijian_btn_fu_zhidong_taban)
    Button acWaijianBtnFuZhidongTaban;
    @BindView(R.id.ac_waijian_fu_zhidong_taban)
    LinearLayout acWaijianFuZhidongTaban;
    @BindView(R.id.ac_waijian_txt_weixian_huowu)
    TextView acWaijianTxtWeixianHuowu;
    @BindView(R.id.ac_waijian_btn_weixian_huowu)
    Button acWaijianBtnWeixianHuowu;
    @BindView(R.id.ac_waijian_weixian_huowu)
    LinearLayout acWaijianWeixianHuowu;

    @BindView(R.id.ac_waijian_luntai_guige)
    LinearLayout acWaijianLuntaiGuige;

    @BindView(R.id.ac_waijian_txt_luntai_guige_l_f)
    TextView acWaijianTxtLuntaiGuigeLF;
    @BindView(R.id.ac_waijian_btn_luntai_guige_l_f)
    Button acWaijianBtnLuntaiGuigeLF;
    @BindView(R.id.ac_waijian_txt_luntai_guige_l_b)
    TextView acWaijianTxtLuntaiGuigeLB;
    @BindView(R.id.ac_waijian_btn_luntai_guige_l_b)
    Button acWaijianBtnLuntaiGuigeLB;
    @BindView(R.id.ac_waijian_txt_luntai_guige_r_f)
    TextView acWaijianTxtLuntaiGuigeRF;
    @BindView(R.id.ac_waijian_btn_luntai_guige_r_f)
    Button acWaijianBtnLuntaiGuigeRF;
    @BindView(R.id.ac_waijian_txt_luntai_guige_r_b)
    TextView acWaijianTxtLuntaiGuigeRB;
    @BindView(R.id.ac_waijian_btn_luntai_guige_r_b)
    Button acWaijianBtnLuntaiGuigeRB;

    @BindView(R.id.ac_waijian_btn_buhege)
    Button acWaijianBtnBuhegeXiangmu;
    @BindView(R.id.ac_waijian_btn_zuoqianfang_45_preview)
    Button acWaijianBtnZuoqianfang45Preview;
    @BindView(R.id.ac_waijian_btn_youhoufang_45_preview)
    Button acWaijianBtnYouhoufang45Preview;
    @BindView(R.id.ac_waijian_btn_shibiedaima_preview)
    Button acWaijianBtnShibiedaimaPreview;
    @BindView(R.id.ac_waijian_btn_anquandai_preview)
    Button acWaijianBtnAnquandaiPreview;
    @BindView(R.id.ac_waijian_btn_xingshi_jilu_preview)
    Button acWaijianBtnXingshiJiluPreview;
    @BindView(R.id.ac_waijian_btn_miehuoqi_preview)
    Button acWaijianBtnMiehuoqiPreview;
    @BindView(R.id.ac_waijian_btn_chexiangneibu_preview)
    Button acWaijianBtnChexiangneibuPreview;
    @BindView(R.id.ac_waijian_btn_cheliang_zhenghoufang_preview)
    Button acWaijianBtnCheliangZhenghoufangPreview;
    @BindView(R.id.ac_waijian_btn_xiaochebiaopai_preview)
    Button acWaijianBtnXiaochebiaopaiPreview;
    @BindView(R.id.ac_waijian_btn_xiaoche_biaozhideng_preview)
    Button acWaijianBtnXiaocheBiaozhidengPreview;
    @BindView(R.id.ac_waijian_btn_xiaoche_tingche_zhishipai_preview)
    Button acWaijianBtnXiaocheTingcheZhishipaiPreview;
    @BindView(R.id.ac_waijian_btn_caozong_fuzhu_preview)
    Button acWaijianBtnCaozongFuzhuPreview;
    @BindView(R.id.ac_waijian_btn_fadongjihao_preview)
    Button acWaijianBtnFadongjihaoPreview;
    @BindView(R.id.ac_waijian_btn_fadongjicang_preview)
    Button acWaijianBtnFadongjicangPreview;
    @BindView(R.id.ac_waijian_btn_yingjichui_preview)
    Button acWaijianBtnYingjichuiPreview;
    @BindView(R.id.ac_waijian_btn_jijiuxiang_preview)
    Button acWaijianBtnJijiuxiangPreview;
    @BindView(R.id.ac_waijian_btn_fangbaosi_preview)
    Button acWaijianBtnFangbaosiPreview;
    @BindView(R.id.ac_waijian_btn_fuzhuzhidong_preview)
    Button acWaijianBtnFuzhuzhidongPreview;
    @BindView(R.id.ac_waijian_btn_jinji_qieduan_preview)
    Button acWaijianBtnJinjiQieduanPreview;
    @BindView(R.id.ac_waijian_btn_shoudong_jixie_preview)
    Button acWaijianBtnShoudongJixiePreview;
    @BindView(R.id.ac_waijian_btn_fu_zhidong_taban_preview)
    Button acWaijianBtnFuZhidongTabanPreview;
    @BindView(R.id.ac_waijian_btn_weixian_huowu_preview)
    Button acWaijianBtnWeixianHuowuPreview;
    @BindView(R.id.ac_waijian_btn_luntai_guige_l_f_preview)
    Button acWaijianBtnLuntaiGuigeLFPreview;
    @BindView(R.id.ac_waijian_btn_luntai_guige_l_b_preview)
    Button acWaijianBtnLuntaiGuigeLBPreview;
    @BindView(R.id.ac_waijian_btn_luntai_guige_r_f_preview)
    Button acWaijianBtnLuntaiGuigeRFPreview;
    @BindView(R.id.ac_waijian_btn_luntai_guige_r_b_preview)
    Button acWaijianBtnLuntaiGuigeRBPreview;
    @BindView(R.id.ac_waijian_xiaochebiaopai_1)
    LinearLayout acWaijianXiaochebiaopai1;
    @BindView(R.id.ac_waijian_txt_xiaochebiaopai2)
    TextView acWaijianTxtXiaochebiaopai2;
    @BindView(R.id.ac_waijian_btn_xiaochebiaopai_preview2)
    Button acWaijianBtnXiaochebiaopaiPreview2;
    @BindView(R.id.ac_waijian_btn_xiaochebiaopai2)
    Button acWaijianBtnXiaochebiaopai2;
    @BindView(R.id.ac_waijian_xiaochebiaopai_2)
    LinearLayout acWaijianXiaochebiaopai2;
    @BindView(R.id.ac_waijian_txt_xiaochebiaopai3)
    TextView acWaijianTxtXiaochebiaopai3;
    @BindView(R.id.ac_waijian_btn_xiaochebiaopai_preview3)
    Button acWaijianBtnXiaochebiaopaiPreview3;
    @BindView(R.id.ac_waijian_btn_xiaochebiaopai3)
    Button acWaijianBtnXiaochebiaopai3;
    @BindView(R.id.ac_waijian_xiaochebiaopai_3)
    LinearLayout acWaijianXiaochebiaopai3;
    @BindView(R.id.ac_waijian_txt_chexiang_yeyabi)
    TextView acWaijianTxtChexiangYeyabi;
    @BindView(R.id.ac_waijian_btn_chexiang_yeyabi_preview)
    Button acWaijianBtnChexiangYeyabiPreview;
    @BindView(R.id.ac_waijian_btn_chexiang_yeyabi)
    Button acWaijianBtnChexiangYeyabi;
    @BindView(R.id.ac_waijian_chexiang_yeyabi)
    LinearLayout acWaijianChexiangYeyabi;
    @BindView(R.id.ac_waijian_photo_listview)
    ListView acWaijianPhotoListview;
    @BindView(R.id.ac_waijian_btn_buhege2)
    Button acWaijianBtnBuhege2;
    @BindView(R.id.ac_waijian_btn_wancheng2)
    Button acWaijianBtnWancheng2;

    @BindView(R.id.ac_waijian_btn_other_imags)
    Button acWaijianBtnOtherImages;

    @BindView(R.id.ac_waijian_photo_scrollview)
    ScrollView acWaijianScrollView;
    @BindView(R.id.ac_waijian_tv_jishiqi_time_time)
    TextView acWaijianTvJishiqi;
    @BindView(R.id.ac_waijian_photo_ll_bottom_layout)
    LinearLayout acWaijianPhotoLlBottomLayout;
    @BindView(R.id.ac_waijian_txt_xiaoche_biaozhideng)
    TextView acWaijianTxtXiaocheBiaozhideng;
    @BindView(R.id.ac_waijian_btn_shipin_start_1)
    Button acWaijianBtnShipinStart1;
    @BindView(R.id.ac_waijian_btn_shipin_end_1)
    Button acWaijianBtnShipinEnd1;
    @BindView(R.id.ac_waijian_btn_shipin_start_2)
    Button acWaijianBtnShipinStart2;
    @BindView(R.id.ac_waijian_btn_shipin_end_2)
    Button acWaijianBtnShipinEnd2;
    @BindView(R.id.ac_waijian_btn_cheliang_tezhengcanshu)
    Button acWaijianBtnTeZhengCanShu;
    @BindView(R.id.ac_waijian_btn_haerbin)
    Button acWaijianBtnHaerbin;
    //endregion
    String tag = "tag";
    private static String dzss = "0";
    // 相册
    private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
    private static final int PICK_IMAGE_ACTIVITY_REQUEST_CODE = 200;
    private static String picFileFullName;
    CarsInforModel carsInforModel;
    private WaiJianPhotoActivity instances = null;
    private String ID = null;//检测车辆ID
    private String carNo = null;//车牌号码
    private String PlateType = null;//号牌种类类型
    private String cartype = null;//车辆类型
    private String PHOTO_TYPE = null;//外检拍照的TYPE上传类型
    private String waijian_chedao = null;//外检车道，检测线代号
    private List<PhotoTypeModel> photoTypeModelList;//照片类型列表

    private int CHECK_MODE = 0;//检测模式 0:外检  1：路试 2：底盘动态
    private String Line = "1";//外检车道
    private String Item_Code = "";//F1外检,R1路试，DC底盘动态
    private WaiJainDataModel waiJainDataModel = new WaiJainDataModel();//外检上传数据model
    private WaiJainDataModel waiJainDataModel2 = new WaiJainDataModel();//外检上传数据model
    private String Login_name = "", login_IDNumber = "";//当前登录的检测员的名字
    //    BaseApplication.mycar_checkItemlList = new ArrayList<>();//获取当前车辆需要的人工检验项目
    private VideoModel model = new VideoModel();
    private List<Boolean> IsTakePhoto = new ArrayList<>();//当前车辆要检测的项目是否拍照的列表
    private String F1_Memo;
//    private String F1_Memo,jianyi;
    String beizhu = "";
    TakePhoto takePhoto;
    Uri imageUri;
    int recLen = 0;
    Handler handler = new Handler();
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            recLen++;
            if (recLen < 1200) {
                acWaijianTvJishiqi.setText("项目进行时间：" + recLen + "  秒");
            }
            handler.postDelayed(this, 1000);
        }
    };
    CountupView mCvCountupViewTest1;
    int gotoTakePhotoCounts = 0;//外检上传自己后台次数
    int gotoTakePhotoCounts2 = 0;//外检上传自己后台次数
    int gotoTakePhotoCounts3 = 0;//平台次数

    static final String[] PERMISSIONS = new String[]{
            Manifest.permission.RECORD_AUDIO,
            Manifest.permission.CAMERA,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };

    private String my_item_start_time = "", my_item_end_time = "";
    private boolean is_db_data = false;//数据库是否保存数据   false:无   true：有
    List<WaiJianItemModel> books = new ArrayList<>();
    String upload_code_str = "", upload_code_str_500 = "";
    static final String STATE_PHOTO_TYPE = "PHOTO_TYPE";
    static final String STATE_PHOTO_TYPE_huan = "PHOTO_TYPE_huan";
    static final String STATE_typeModel = "typeModel";
    static final String STATE_TypeModel_Position = "TypeModel_Position";
    static final String STATE_my_item_start_time = "my_item_start_time";
    static final String STATE_typeModelListAdapter = "typeModelListAdapter";

    boolean is_500 = false;
    private String isYasuoPhoto;

    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {
        // 保存用户自定义的状态
        savedInstanceState.putString(STATE_PHOTO_TYPE, PHOTO_TYPE);
        savedInstanceState.putSerializable(STATE_typeModel, typeModel);
        savedInstanceState.putInt(STATE_TypeModel_Position, TypeModel_Position);
        savedInstanceState.putString(STATE_my_item_start_time, my_item_start_time);
//        savedInstanceState.putSerializable(STATE_typeModelListAdapter, (Serializable) typeModelListAdapter);
        // 调用父类交给系统处理，这样系统能保存视图层次结构状态
        super.onSaveInstanceState(savedInstanceState);
    }

    public void onRestoreInstanceState(Bundle savedInstanceState) {
        // 总是调用超类，以便它可以恢复视图层次超级
        super.onRestoreInstanceState(savedInstanceState);
        // 从已保存的实例中恢复状态成员
        PHOTO_TYPE = savedInstanceState.getString(STATE_PHOTO_TYPE);
        typeModel = (TypeModel) savedInstanceState.getSerializable(STATE_typeModel);
        TypeModel_Position = savedInstanceState.getInt(STATE_TypeModel_Position);
        my_item_start_time = savedInstanceState.getString(STATE_my_item_start_time);
//        typeModelListAdapter = (List<TypeModel>) savedInstanceState.getSerializable(STATE_typeModel);
    }

    private StationInforModel stationInforModel;
    String up_json_str = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        setContentView(R.layout.activity_wai_jian_photo);
        ButterKnife.bind(this);
        String logStrf = "\n" + "onCreate-----外检拍照---WaiJianPhotoActivity-----" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());

        DialogSettings.style = (DialogSettings.STYLE.STYLE_KONGZUE);
        DialogSettings.init();
        if (EasyPermissions.hasPermissions(this, PERMISSIONS)) {//检查是否获取该权限
            UtilsLog.e("zzl=已获取权限");
        } else {
            UtilsLog.e("zzl=meiyou===权限");
            EasyPermissions.requestPermissions(this, "必要的权限", 0, PERMISSIONS);
        }
        instances = this;
        isYasuoPhoto = SharedPreferencesUtils.getIsYasuoPhoto(instances);
        waiJianPhoto_buhege_List = new ArrayList<>();
        mCvCountupViewTest1 = (CountupView) findViewById(R.id.ac_waijian_tv_jishiqi_cv_CountupViewTest3);
        mCvCountupViewTest1.setTag("test1");
        long time1 = (long) 1000;
        mCvCountupViewTest1.start(time1);
//        handler.postDelayed(runnable, 1000);
//        setBackBtn();

//        setTopTitle(R.string.ac_waijian_title);

        WAIJIAN_PHOTO_PREVIEW_LISTS = new HashMap<>();

        waijian_chedao = getIntent().getExtras().getString("CarDetailsActivity_acCarDetailsWaijianchedao",
                "");
        F1_Memo = getIntent().getExtras().getString("EngineNOFlag", "");
//        jianyi= getIntent().getExtras().getString("jianyi", "");
        carsInforModel = (CarsInforModel) getIntent().getSerializableExtra
                ("CarDetailsActivity_CarsInforModel");
        UtilsLog.e("carsInforModel=55=" + carsInforModel.toString());


        UtilsLog.e("WaiJianPhotoActivity---ElectronicHandbrake=====" + carsInforModel.getElectronicHandbrake());
//        carsInforModel = getIntent().getExtras().getParcelable("CarDetailsActivity_CarsInforModel");
        UtilsLog.e("F1_Memo=" + F1_Memo);
//        UtilsLog.e("jianyi=" + jianyi);
        Login_name = getIntent().getExtras().getString("login_w_name", "");
        UtilsLog.e("Login_name=Login_name=" + Login_name);
        login_IDNumber = getIntent().getExtras().getString("login_IDNumber", "");
        UtilsLog.e("login_IDNumber=login_IDNumber=" + login_IDNumber);
        dzss = getIntent().getExtras().getString("dzss", "");
        UtilsLog.e("dzss=" + dzss);
        String logStrf2 = "\n" + "onCreate-----外检拍照---WaiJianPhotoActivity-----" + "\n" +
                "ElectronicHandbrake==" + carsInforModel.getElectronicHandbrake() + "\n"
                + "DetectCategory==" + carsInforModel.getDetectCategory() + "\n"
                + "dzss==" + dzss + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf2.getBytes());
//        String logStrf1 = "\n" + "-----外检拍照---dzss-----" + dzss + "\n";
//        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf1.getBytes());
        my_item_start_time = getIntent().getExtras().getString("start_time", "");
        if (TextUtils.isEmpty(my_item_start_time) || my_item_start_time.equals("")) {
            my_item_start_time = DateUtil.currentTime2();
        }
        initView();
//        verifyStoragePermissions(instances);
        //检测车辆ID
        ID = String.valueOf(carsInforModel.getID());
        //车牌号码
        if (!TextUtils.isEmpty(carsInforModel.getPlateRegion()) && !TextUtils.isEmpty(carsInforModel
                .getPlateNO())) {
            carNo = carsInforModel.getPlateRegion() + carsInforModel.getPlateNO();
        }
        //号牌类型
        if (!TextUtils.isEmpty(carsInforModel.getPlateTypeName())) {
            PlateType = String.valueOf(carsInforModel.getPlateTypeName());
        }
        //车辆类型
        if (!TextUtils.isEmpty(carsInforModel.getType())) {
            cartype = String.valueOf(carsInforModel.getType());
        }
        //获取去图片类型列表
//        getDataPhotoTypeList();

        CHECK_MODE = BaseApplication.JIANCE_MODE;
        UtilsLog.e("WaiJianPhotoActivity---CHECK_MODE==" + CHECK_MODE);
        Line = getIntent().getStringExtra("CarDetailsActivity_Line");
        switch (CHECK_MODE) {
            case 0:
                Item_Code = "F1";
                break;
            case 1:
                Item_Code = "R1";
                break;
            case 2:
                Item_Code = "DC";
                break;
        }


//        //哈尔滨地区--结束按钮
        if (SharedPreferencesUtils.getHaErBinVersion(instances)) {
//            acWaijianBtnHaerbin.setVisibility(View.VISIBLE);
            acWaijianBtnHaerbin.setVisibility(View.GONE);
//            getOutPhotoItem();
            getStationInfor();
//            getMyCarItems();
//            initDataToHaerbin();
        } else {
            acWaijianBtnHaerbin.setVisibility(View.GONE);
        }

        //绕车一周视频
        if (SharedPreferencesUtils.getRaoCheYiZhouVideo(instances)) {
            acWaijianBtnShipinStart1.setVisibility(View.VISIBLE);
        } else {
            acWaijianBtnShipinStart1.setVisibility(View.GONE);
        }

        if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
            myChoiceModelList.clear();
        }
        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
        Item_2Model item_2 = null;
        for (int i = 0; i < BaseApplication.checkItemModelList.size(); i++) {
            item_2 = new Item_2Model();
            item_2.setID(BaseApplication.checkItemModelList.get(i).getID());
            item_2.setCode1(BaseApplication.checkItemModelList.get(i).getCode1());
            item_2.setCode2(BaseApplication.checkItemModelList.get(i).getCode2());
            item_2.setName2(BaseApplication.checkItemModelList.get(i).getName2());
            Item_2Model_list.add(item_2);
        }
        for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
            for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                    Item_2Model_list.remove(j);
                }
            }
        }
        for (int i = 0; i < Item_2Model_list.size(); i++) {
            MyChoiceModel model = new MyChoiceModel();
            model.setCode2(Item_2Model_list.get(i).getCode2());
            model.setChecked(true);
            model.setName2(Item_2Model_list.get(i).getName2());
            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
            model.setCode_values("0");
            myChoiceModelList_waijian.add(model);
        }
//        if (IsFirst) {
//            if (true) {
        for (int i = 0; i < Item_2Model_list.size(); i++) {
            // UtilsLog.e("Item_2Model_list=11=" + Item_2Model_list.get(i).toString());
            MyChoiceModel model = new MyChoiceModel();
            model.setCode2(Item_2Model_list.get(i).getCode2());
            model.setChecked(true);
            model.setName2(Item_2Model_list.get(i).getName2());
            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
            model.setCode_values("0");
            myChoiceModelList.add(model);
        }

//        getMyCarItems();

        init();
        getOutPhotoItem();

        BaseApplication.BaseApplication_buHeGeModel3List = new ArrayList<>();
//        appendCode2AndValues();

        dzss = BaseApplication.DZSS;

        if (SharedPreferencesUtils.getYunNan(this)) {
            goOnItemEnd = false;
        } else {
            goOnItemEnd = true;
        }
    }

    void bb() {
        is_get_first = true;
        getGET_ALL_ITEMList();
        if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
            myChoiceModelList.clear();
        }
//        myChoiceModelList_waijian = new ArrayList<>();
        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
        Item_2Model item_2 = null;
        if (BaseApplication.checkItemModelList != null &&
                BaseApplication.checkItemModelList.size() > 0) {
            for (int i = 0; i < BaseApplication.checkItemModelList.size(); i++) {
                item_2 = new Item_2Model();
                item_2.setID(BaseApplication.checkItemModelList.get(i).getID());
                item_2.setCode1(BaseApplication.checkItemModelList.get(i).getCode1());
                item_2.setCode2(BaseApplication.checkItemModelList.get(i).getCode2());
                item_2.setName2(BaseApplication.checkItemModelList.get(i).getName2());
                Item_2Model_list.add(item_2);
            }
            for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                    if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                        Item_2Model_list.remove(j);
                    }
                }
            }
            for (int i = 0; i < Item_2Model_list.size(); i++) {
                // UtilsLog.e("Item_2Model_list=11=" + Item_2Model_list.get(i).toString());
                MyChoiceModel model = new MyChoiceModel();
                model.setCode2(Item_2Model_list.get(i).getCode2());
                model.setChecked(true);
                model.setName2(Item_2Model_list.get(i).getName2());
                model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                model.setCode_values("0");
                myChoiceModelList.add(model);
            }
        } else {

        }
        getMyCarItems();
//        if (myChoiceModelList_waijian != null && myChoiceModelList_waijian.size() > 0) {
//            for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
////                UtilsLog.e("看这个==myChoiceModelList_waijian==" + myChoiceModelList_waijian.get(i).toString());
//            }
//        }
    }


    //获取所有人工检验项目接口
    private void getGET_ALL_ITEMList() {
        String url = "";
        url = GET_ALL_ITEM38900;
        String logStr = "\n" + "获取所有人工检验项目接口----" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(instances) + url + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getGET_ALL_ITEMList---url==" + SharedPreferencesUtils.getIP(instances) + url);
        OkGo.<String>get(SharedPreferencesUtils.getIP(instances) + url).tag(instances)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
//                        CommonUtils.hideLoadingDialog(instances);
                        String result = response.body();
//                        UtilsLog.e("getGET_ALL_ITEMList-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
//                        UtilsLog.e("getGET_ALL_ITEMList-newResult==" + newResult);
                        String logStr = "\n" + "=====获取所有人工检验项目接口----onSuccess" + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        String logStr2 = "\n" + "获取所有人工检验项目接口----onSuccess" + "\n" + "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
                                (newResult) && !"[]".equals(result)) {
                            List<CheckItemModel> checkItemModelList2 = new ArrayList<>();
                            myChoiceModelList_waijian = new ArrayList<>();
                            checkItemModelList = new ArrayList<CheckItemModel>();
                            checkItemModelList = JsonUtil.stringToArray(newResult, CheckItemModel[].class);
                            checkItemModelList2 = JsonUtil.stringToArray(newResult, CheckItemModel[].class);

//                            myChoiceModelList_waijian = new ArrayList<>();
                            List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                            Item_2Model item_2 = null;
                            if (checkItemModelList2 != null && checkItemModelList2.size() > 0) {
                                for (int i = 0; i < checkItemModelList2.size(); i++) {
                                    item_2 = new Item_2Model();
                                    item_2.setID(checkItemModelList2.get(i).getID());
                                    item_2.setCode1(checkItemModelList2.get(i).getCode1());
                                    item_2.setCode2(checkItemModelList2.get(i).getCode2());
                                    item_2.setName2(checkItemModelList2.get(i).getName2());
                                    Item_2Model_list.add(item_2);
                                }
                                for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                                    for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                        if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                                            Item_2Model_list.remove(j);
                                        }
                                    }
                                }
//                                for (int i = 0; i < Item_2Model_list.size(); i++) {
//                                    MyChoiceModel model = new MyChoiceModel();
//                                    model.setCode2(Item_2Model_list.get(i).getCode2());
//                                    model.setChecked(true);
//                                    model.setName2(Item_2Model_list.get(i).getName2());
//                                    model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
//                                    model.setCode_values("0");
//                                    myChoiceModelList_waijian.add(model);
//                                }
                            } else {
                                Toast.makeText(instances, "获取所有人工检测项目内容失败，请重试",
                                        Toast.LENGTH_LONG).show();
                            }


                        } else {
//                            Toast.makeText(instances, getResources().getString(R.string.network_error),
// Toast.LENGTH_LONG).show();
                            UtilsLog.e("getGET_ALL_ITEMList-result==" + "没有数据");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
//                        CommonUtils.hideLoadingDialog(instances);
                        UtilsLog.e("getGET_ALL_ITEMList-onError==" + response.body());
                        String logStr = "\n" + "获取所有人工检验项目接口----onError" + "\n" + "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        Toast.makeText(WaiJianPhotoActivity.this, getResources().getString(R.string.services_error), Toast
                                .LENGTH_LONG).show();
                    }
                });
    }

    boolean is_get_first = false;

    @Override
    protected void onResume() {
        super.onResume();
        UtilsLog.e("外检拍照---BaseApplication.DZSS==" + dzss);
//        if (is_get_first = false) {
            bb();
//        }
//        books = WaiJianItemModel.listAll(WaiJianItemModel.class);
        books = WaiJianItemModel.find(WaiJianItemModel.class, "SN=?", carsInforModel.getSN());

        if (books != null && books.size() > 0) {
            is_db_data = true;
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询----不为空==" + books.toString());
//            for (int i = 0; i < books.size(); i++) {
////                WaiJianItemModel.delete(books.get(i));
//            }
        } else {
            is_db_data = false;
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询----空==");
        }
//        dbModelData(false, true);
//        for (int i = 0; i < myChoiceModelList.size(); i++) {
//            UtilsLog.e("看这个==myChoiceModelList==" + myChoiceModelList.get(i).toString());
//        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        // 将结果转发给 EasyPermissions
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
        Log.e("tag", "onRequestPermissionsResult:" + "== requestCode:" + requestCode +
                "===permissions==" + permissions.length +
                "===grantResults==" + grantResults.length);
    }


    @Override
    public void takeCancel() {
        super.takeCancel();
    }

    @Override
    public void takeFail(TResult result, String msg) {
        super.takeFail(result, msg);
        Log.e("photo", "拍照失败==" + msg);
        String logStr = "\n" + "外检项目拍照----拍照失败==" + "\n" + msg;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        ArrayList<TImage> images = result.getImages();
        if (images != null && images.size() > 0) {
            String photo_file_path = images.get(0).getCompressPath();
            String photo_file_path2 = images.get(0).getOriginalPath();
            Log.e("photo", "拍照失败--path==" + photo_file_path);
            Log.e("photo", "拍照失败--path=22=" + photo_file_path2);
        }
    }

    //    String photo_file_path;
    String photo_file_path_OriginalPath;
    int FLAG = 1;//0:拍照   1：相册
    private List<String> flagImagesUrls = new ArrayList<>();
    private List<Integer> flagImagesUrlsPosition = new ArrayList<>();

    @Override
    public void takeSuccess(TResult result) {
        super.takeSuccess(result);
        Log.e("photo", "111111111111");
        if (result != null) {
//            showImg(result.getImages());
            ArrayList<TImage> images = result.getImages();
            if (images != null && images.size() > 0) {
                //压缩后的图片路径，不压缩为null
//                photo_file_path = images.get(0).getCompressPath();
                Log.e("photo", "拍照成功--path=111=" + images.get(0).getOriginalPath());
                Log.e("photo", "拍照成功--path=Environment=" + Environment.getExternalStorageDirectory());
                ///storage/emulated/0
                if (FLAG == 1) {
                    //拍照
                    if (SystemUtil.getSystemModel().contains("GIONEE") || SystemUtil.getSystemModel().contains("gionee")) {
                        //金立手机的路线
                        photo_file_path_OriginalPath = Environment.getExternalStorageDirectory() + images.get(0)
                                .getOriginalPath().replace("my_images/", "").replace(external_path2, "");
                        Log.e("photo", "拍照成功-金立手机-path=22=" + photo_file_path_OriginalPath);
                    } else {
                        //其他手机
                        /***
                         * @question 拍照返回的照片的路径处理
                         * @method 有的手机返回的照片带有/storage/emulated/0，
                         * @method 有的不带，所以需要分别处理
                         * @import 找个地方划重点，考试要考的，TDM CD
                         */
                        if (images.get(0).getOriginalPath().contains("storage/emulated")) {
                            photo_file_path_OriginalPath = images.get(0).getOriginalPath().replace("my_images/", "").replace(external_path2, "");
                        } else {
                            photo_file_path_OriginalPath = Environment.getExternalStorageDirectory() + images.get(0)
                                    .getOriginalPath().replace("my_images/", "").replace(external_path2, "");
                        }
//                    photo_file_path_OriginalPath = Environment.getExternalStorageDirectory() + images.get(0)
//                            .getOriginalPath().replace("my_images/", "");
                        Log.e("photo", "拍照成功--path=22=" + photo_file_path_OriginalPath);
                    }
                } else if (FLAG == 2) {
                    //相册
                    photo_file_path_OriginalPath = images.get(0)
                            .getOriginalPath().replace("my_images/", "").replace(external_path2, "");
                    Log.e("photo", "相册--path=2234343434=" + photo_file_path_OriginalPath);
                } else if (FLAG == 0) {
                    photo_file_path_OriginalPath = images.get(0)
                            .getOriginalPath().replace("my_images/", "").replace(external_path2, "");
                    Log.e("photo", "相册--相册====" + photo_file_path_OriginalPath);


                    //                        FileInputStream in = new FileInputStream(photo_file_path_OriginalPath);
//                        Bitmap bitmap = BitmapFactory.decodeStream(in);
//                        MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "", "");
//                    Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
//                    Uri uri = Uri.fromFile(new File("/sdcard/image.jpg"));
//                    intent.setData(uri);
//                    instances.sendBroadcast(intent);
//                    //从相册中选取不裁剪
//                    takePhoto.onPickFromGallery();
                }
                if (!TextUtils.isEmpty(photo_file_path_OriginalPath)) {
                    //拍照不需要编辑的
                    if (isYasuoPhoto.equals("是")) {
                        Luban.with(instances)
                                .load(new File(photo_file_path_OriginalPath))                     //传人要压缩的图片
                                .setCompressListener(new OnCompressListener() { //设置回调
                                    @Override
                                    public void onStart() {
                                        // TODO 压缩开始前调用，可以在方法内启动 loading UI
                                    }

                                    @Override
                                    public void onSuccess(File file) {
                                        // TODO 压缩成功后调用，返回压缩后的图片文件
                                        Log.e("photo", "压缩成功后调用");
                                        //拍照压缩后上传
//                                    getData(file,picFileFullName);
                                        getData(file, photo_file_path_OriginalPath);
                                    }

                                    @Override
                                    public void onError(Throwable e) {
                                        // TODO 当压缩过程出现问题时调用
                                        Toast.makeText(instances, "图片压缩出现问题，请重试", Toast.LENGTH_LONG).show();
                                    }
                                }).launch();    //启动压缩
                    } else {
                        getData(new File(photo_file_path_OriginalPath), photo_file_path_OriginalPath);
                    }

                }
//                }
            }
        }
    }

    private void initView() {
        //操纵辅助装置  残疾人专用汽车
        acWaijianCaozongFuzhu.setVisibility(View.GONE);
    }

    @OnClick({R.id.ac_waijian_btn_caozong_fuzhu, R.id.ac_waijian_btn_fadongjihao,
            R.id.ac_waijian_btn_fadongjicang, R.id.ac_waijian_btn_yingjichui, R.id.ac_waijian_btn_jijiuxiang,
            R.id.ac_waijian_btn_fuzhuzhidong, R.id.ac_waijian_btn_jinji_qieduan,
            R.id.ac_waijian_btn_shoudong_jixie, R.id.ac_waijian_btn_fu_zhidong_taban,
            R.id.ac_waijian_btn_weixian_huowu, R.id.ac_waijian_btn_zuoqianfang_45,
            R.id.ac_waijian_btn_youhoufang_45, R.id.ac_waijian_btn_shibiedaima, R.id.ac_waijian_btn_anquandai,
            R.id.ac_waijian_btn_xingshi_jilu, R.id.ac_waijian_btn_miehuoqi, R.id.ac_waijian_btn_chexiangneibu,
            R.id.ac_waijian_btn_cheliang_zhenghoufang, R.id.ac_waijian_btn_xiaochebiaopai,
            R.id.ac_waijian_btn_xiaoche_biaozhideng, R.id.ac_waijian_btn_xiaoche_tingche_zhishipai,
            R.id.ac_waijian_btn_wancheng, R.id.ac_waijian_btn_fangbaosi,
            R.id.ac_waijian_btn_luntai_guige_l_f, R.id.ac_waijian_btn_luntai_guige_l_b,
            R.id.ac_waijian_btn_luntai_guige_r_f, R.id.ac_waijian_btn_luntai_guige_r_b,
            R.id.ac_waijian_btn_buhege, R.id.ac_waijian_btn_zuoqianfang_45_preview,
            R.id.ac_waijian_btn_youhoufang_45_preview,
            R.id.ac_waijian_btn_shibiedaima_preview, R.id.ac_waijian_btn_anquandai_preview,
            R.id.ac_waijian_btn_xingshi_jilu_preview, R.id.ac_waijian_btn_miehuoqi_preview,
            R.id.ac_waijian_btn_chexiangneibu_preview, R.id.ac_waijian_btn_xiaochebiaopai_preview,
            R.id.ac_waijian_btn_xiaoche_biaozhideng_preview, R.id
            .ac_waijian_btn_xiaoche_tingche_zhishipai_preview,
            R.id.ac_waijian_btn_caozong_fuzhu_preview, R.id.ac_waijian_btn_fadongjihao_preview,
            R.id.ac_waijian_btn_fadongjicang_preview, R.id.ac_waijian_btn_yingjichui_preview,
            R.id.ac_waijian_btn_jijiuxiang_preview, R.id.ac_waijian_btn_fangbaosi_preview,
            R.id.ac_waijian_btn_fuzhuzhidong_preview, R.id.ac_waijian_btn_jinji_qieduan_preview,
            R.id.ac_waijian_btn_shoudong_jixie_preview, R.id.ac_waijian_btn_fu_zhidong_taban_preview,
            R.id.ac_waijian_btn_weixian_huowu_preview, R.id.ac_waijian_btn_luntai_guige_l_f_preview,
            R.id.ac_waijian_btn_luntai_guige_l_b_preview, R.id.ac_waijian_btn_luntai_guige_r_f_preview,
            R.id.ac_waijian_btn_luntai_guige_r_b_preview, R.id.ac_waijian_btn_cheliang_zhenghoufang_preview,
            R.id.ac_waijian_btn_xiaochebiaopai_preview2, R.id.ac_waijian_btn_xiaochebiaopai2,
            R.id.ac_waijian_btn_xiaochebiaopai_preview3, R.id.ac_waijian_btn_xiaochebiaopai3,
            R.id.ac_waijian_btn_chexiang_yeyabi_preview, R.id.ac_waijian_btn_chexiang_yeyabi,
            R.id.ac_waijian_btn_buhege2, R.id.ac_waijian_btn_wancheng2,
            R.id.ac_waijian_btn_other_imags, R.id.ac_waijian_btn_haerbin,
            R.id.ac_waijian_btn_shipin_start_1, R.id.ac_waijian_btn_shipin_end_1,
            R.id.ac_waijian_btn_shipin_start_2, R.id.ac_waijian_btn_shipin_end_2
            , R.id.ac_waijian_btn_cheliang_tezhengcanshu})
    public void onViewClicked(View view) {
            switch (view.getId()) {
                case R.id.ac_waijian_btn_haerbin:
                    if (SharedPreferencesUtils.getHaErBinVersion(instances)) {
                        //哈尔滨地区  跳转第三方拍照
                        gotoApp();
                    }
                    break;
                case R.id.ac_waijian_btn_cheliang_tezhengcanshu:
                    //特征参数
                    Intent intent_te = new Intent(instances, WaiJianItemActivity.class);
                    intent_te.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
                    intent_te.putExtra("CarDetailsActivity_Line", waijian_chedao);
                    intent_te.putExtra("login_w_name", Login_name);
                    intent_te.putExtra("login_IDNumber", login_IDNumber);
                    startActivity(intent_te);
                    break;
                case R.id.ac_waijian_btn_shipin_start_1:
                    //绕车一周视频
                    Intent intent_video_1 = new Intent(instances, VideoRecorderActivity.class);
//                Intent intent_video_1 = new Intent(instances, VideoListActivity.class);
                    intent_video_1.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
                    intent_video_1.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
                            waijian_chedao);
                    intent_video_1.putExtra("video_type", 1);
                    intent_video_1.putExtra("CarDetailsActivity_Line", Line);
                    startActivity(intent_video_1);
                    break;
                case R.id.ac_waijian_btn_shipin_end_1:
                    //VIN码拍照
                    takePhoto = getTakePhoto();
                    File file = new File(Environment.getExternalStorageDirectory(), external_path + "/temp_my_app/" + System
                            .currentTimeMillis() + ".jpg");
                    if (!file.getParentFile().exists()) {
                        file.getParentFile().mkdirs();
                    }
                    imageUri = Uri.fromFile(file);
                    Logger.d("photo", "waijian--VIN--image==" + imageUri);
                    img_imageUri_path = imageUri.getPath();
                    Logger.d("photo", "waijian--VIN--image==" + imageUri.getPath());
                    takePhoto.onPickFromCapture(imageUri);
                    break;
                case R.id.ac_waijian_btn_shipin_start_2:

                    break;
                case R.id.ac_waijian_btn_shipin_end_2:

                    break;
                case R.id.ac_waijian_btn_wancheng2:
                    //外检完成
                    UtilsLog.e("外检完成--mm时间====" + mCvCountupViewTest1.getMinute());
                    UtilsLog.e("外检完成--s时间====" + mCvCountupViewTest1.getSecond());
                    String logStr = "\n" + "点击外检完成按钮--111-" + "\n" +
                            "大车开关===" + SharedPreferencesUtils.getDaChe(instances) + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    UtilsLog.e("getUseProperty==" + carsInforModel.getUseProperty());
                    UtilsLog.e("getType==" + carsInforModel.getType());
                    UtilsLog.e("getType=22=" + carsInforModel.getType().contains("K3"));
                    if (!goOnItemEnd) {
                        waiJianPhoto();
                    }

                    if (goOnItemEnd) {

//                if (SharedPreferencesUtils.getHaErBinVersion(instances)) {
                        // 哈尔滨地区要限值时间小车120秒，大车240秒
                        if (SharedPreferencesUtils.getDaChe(instances)) {
                            if (carsInforModel.getUseProperty().equals("A")
                                    && (carsInforModel.getType().contains("K3")
                                    || carsInforModel.getType().contains("K4"))
                                    ) {
                                //非营运小型微型载客汽车--xiaoche
                                if (mCvCountupViewTest1.getMinute() >= 2) {
                                    WJFinish();
                                } else {
                                    Toast.makeText(instances, "时间未达120s，项目无法结束", Toast.LENGTH_LONG).show();
                                }
                            } else if (carsInforModel.getType().contains("M")
                                    || carsInforModel.getType().contains("N")
                                    ) {
                                //摩托车、三轮汽车
                                if (mCvCountupViewTest1.getSecond() >= 1) {
                                    WJFinish();
                                } else {
                                    Toast.makeText(instances, "时间未达90s，项目无法结束", Toast.LENGTH_LONG).show();
                                }
                            } else {
                                //大车
                                if (mCvCountupViewTest1.getMinute() >= 4) {
                                    WJFinish();
                                } else {
                                    Toast.makeText(instances, "时间未达240s，项目无法结束", Toast.LENGTH_LONG).show();
                                }
                            }
                        } else {
                            WJFinish();
                        }
//                } else {
//                    //其他地区暂时不做限值
//                    WJFinish();
//                }
                    } else {

                    }

                    break;
                case R.id.ac_waijian_btn_buhege2:
                    String logStr2 = "\n" + "外检不合格项目按钮点击" + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                    //不合格项目录入
//                Intent intent = new Intent(WaiJianPhotoActivity.this, DisqualificationActivity.class);
//                intent.putExtra("buhege_flag", 0);//不合格项目跳转 0：外检 1：底盘动态
//                intent.putExtra("WaiJianPhotoActivity_CarsInforModel", carsInforModel);
//                startActivity(intent);
                    getMyCarItems();

                    Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            Intent intent_2 = new Intent(WaiJianPhotoActivity.this, WaiJianResultActivity.class);
                            intent_2.putExtra("WaiJianPhotoActivity_CarsInforModel", carsInforModel);
                            startActivityForResult(intent_2, 500);
                        }
                    }, 400);//后执行Runnable中的run方法

                    break;
                case R.id.ac_waijian_btn_other_imags:
                    String logStr3 = "\n" + "外检-其他拍照照片按钮点击" + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr3.getBytes());
                    Intent intent_3 = new Intent(WaiJianPhotoActivity.this, OtherWaiJianPhotoActivity.class);
                    startActivityForResult(intent_3, 404);
                    break;
            }
        }

        AlertDialog.Builder builderPhoto = null;
        boolean goOnItemEnd = false;

    void waiJianPhoto() {
        List<String> photoList = new ArrayList<>();
        for (int i = 0; i < typeModelListAdapter.size(); i++) {
            if (typeModelListAdapter.get(i).getColor() == 0) {
                photoList.add(typeModelListAdapter.get(i).getName());
            }
        }
        if (photoList != null && photoList.size() > 0) {
            String[] photos = new String[photoList.size()];
            for (int i = 0; i < photoList.size(); i++) {
                photos[i] = photoList.get(i);
            }
            builderPhoto = new AlertDialog.Builder
                    (instances);
            builderPhoto.setTitle("提示:有未完成的拍照");
//            builder.setMessage(content);
            builderPhoto.setItems(photos, null);
            builderPhoto.setNegativeButton("继续拍照", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    goOnItemEnd = false;
                    dialog.dismiss();
                }
            });
            builderPhoto.setPositiveButton("项目结束", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    goOnItemEnd = true;
                    dialog.dismiss();
                }
            });
            builderPhoto.show();
        }
//        return goOnItemEnd;
    }

    //外检完成上传数据
    private void WJFinish() {
        CommonUtils.showLoadingDialog(WaiJianPhotoActivity.this, "加载中...");
        waiJainDataModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
        waiJainDataModel.setGUID(carsInforModel.getGUID());
        waiJainDataModel.setDetectionDevID(SharedPreferencesUtils.getIMEI(instances));
//                waiJainDataModel.setElectronicHandbrake(carsInforModel.getElectronicHandbrake());
        waiJainDataModel.setBrakeForce(carsInforModel.getBrakeForce());
//                waiJainDataModel.setPlateNO(carsInforModel.getPlateNO());
        waiJainDataModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        waiJainDataModel.setAirAdmission(carsInforModel.getAirAdmission());
        waiJainDataModel.setTimes(carsInforModel.getTimes());
        try {
            String name = URLDecoder.decode(Login_name, "UTF-8");
            waiJainDataModel.setAppearanceInspector(name);//检测员名字，汉字
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        waiJainDataModel.setLeadTruck(Login_name);
        waiJainDataModel.setAppearanceNo(login_IDNumber);
        waiJainDataModel.setApprovedLoad(carsInforModel.getApprovedLoad());
        waiJainDataModel.setArea(carsInforModel.getArea());
        waiJainDataModel.setBodyColor(carsInforModel.getBodyColor());
        waiJainDataModel.setBrand(carsInforModel.getBrand());
        waiJainDataModel.setCarBodyType(carsInforModel.getCarBodyType());
        waiJainDataModel.setCarID(carsInforModel.getCarID());
        waiJainDataModel.setCarModel(carsInforModel.getCarModel());
        waiJainDataModel.setCarTypeLevel(carsInforModel.getCarTypeLevel());
        waiJainDataModel.setCategory(carsInforModel.getCategory());
        waiJainDataModel.setCentralAxle(carsInforModel.getCentralAxle());
        waiJainDataModel.setCode(carsInforModel.getCode());
        waiJainDataModel.setCombCarNO(carsInforModel.getCombCarNO());
        waiJainDataModel.setCurbWeight(carsInforModel.getCurbWeight());
        waiJainDataModel.setDetectDate(carsInforModel.getDetectDate());
        waiJainDataModel.setDetectionCategory(carsInforModel.getDetectionCategory());
        waiJainDataModel.setDetectionStatus(carsInforModel.getDetectionStatus());
        waiJainDataModel.setDisplacement(carsInforModel.getDisplacement());
        waiJainDataModel.setDriveAxle(carsInforModel.getDriveAxle());
        waiJainDataModel.setDriverAxleWeight(carsInforModel.getDriverAxleWeight());
        waiJainDataModel.setDriverTypeName(carsInforModel.getDriverTypeName());
        waiJainDataModel.setDriverType(carsInforModel.getDriverType());
        waiJainDataModel.setPlateType(carsInforModel.getPlateType());
        waiJainDataModel.setItemcode(Item_Code);
        waiJainDataModel.setLine(Line);
        waiJainDataModel.setMainAxis(carsInforModel.getMainAxis());
        waiJainDataModel.setParkingAxle(carsInforModel.getParkingAxle());
        waiJainDataModel.setEngineNO(carsInforModel.getEngineNO());
        waiJainDataModel.setFuelType(carsInforModel.getFuelType());
        waiJainDataModel.setPlateTypeName(carsInforModel.getPlateTypeName());
        waiJainDataModel.setPlatformSN(carsInforModel.getPlatformSN());
        waiJainDataModel.setQueueID(carsInforModel.getQueueID());
        waiJainDataModel.setSN(carsInforModel.getSN());
        waiJainDataModel.setStatus(carsInforModel.getStatus());
        waiJainDataModel.setTest_times(carsInforModel.getTimes());
        waiJainDataModel.setType(carsInforModel.getType());
        waiJainDataModel.setVIN(carsInforModel.getVIN());
//                appendCode2AndValues();

        model.setItemcode(Item_Code);
        model.setLine(Line);
        model.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        model.setPlateType(carsInforModel.getPlateType());
        model.setPlatformSN(carsInforModel.getPlatformSN());
        model.setTest_times(carsInforModel.getTimes());

        if (CommonUtils.isOnline(instances)) {
            //上传平台的数据
            waiJainDataModel.setDataType("F1");
            Gson gson = new Gson();
            String jsonStr = gson.toJson(waiJainDataModel);
            try {
                JSONObject jsonObject = new JSONObject(jsonStr);
//                UtilsLog.e("jsonStr======uploadPlatformData_w====111====" + jsonObject.toString());
                if (!jsonObject.isNull("Remark")) {
                    jsonObject.remove("Remark");
                }
                jsonStr = jsonObject.toString();
//                UtilsLog.e("jsonStr======uploadPlatformData_w===22=====" + jsonStr);
            } catch (JSONException e) {
                e.printStackTrace();
            }
//            UtilsLog.e("jsonStr======uploadPlatformData_w===33=====" + jsonStr);
            if (!TextUtils.isEmpty(jsonStr)) {
                String str = jsonStr.substring(1, jsonStr.length() - 1);
                UtilsLog.e("jsonStr======uploadPlatformData_w===str=====" + str);

                if (carsInforModel.getDetectionCategory().equals("99")) {
                    UtilsLog.e("99999999999999999999r=====" + str);
                    String logStrf1 = "\n" + "-----外检拍照---DetectionCategory---99999--"
                            + carsInforModel.getDetectionCategory() + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf1.getBytes());
                    BaseApplication.W_ItemEnd_time = "";
                    BaseApplication.W_ItemEnd_time = DateUtil.currentTime2();
                    my_item_end_time = BaseApplication.W_ItemEnd_time;

                    getDataReportData();
                    Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            getDataReportData2();
                        }
                    }, 500);//后执行Runnable中的run方法
                    //新国标升级上传本地后台数据
                    initJsonDataToPlateform(BaseApplication.W_ItemEnd_time);
//                            Toast.makeText(instances, "外检项目完成", Toast
//                                    .LENGTH_LONG).show();
//                            EndAllItem(String.valueOf(carsInforModel.getID()));
                    updateCarStatusInfor(1);
                    acWaijianBtnWancheng2.setEnabled(true);
                    Handler handler22 = new Handler();
                    handler22.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            //项目总结束
//                                updateCarStatusInfor(1);
                            EndAllItem(String.valueOf(carsInforModel.getID()));
                        }
                    }, 700);//后执行Runnable中的run方法

                } else {
                    String logStrf1 = "\n" + "-----外检拍照---DetectionCategory---不是99999--"
                            + carsInforModel.getDetectionCategory() + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf1.getBytes());
                    uploadPlatformData_w(jsonStr);
                }
            }
//                    uploadPlatformData_w(jsonStr);
//                    Handler handler = new Handler();
//                    handler.postDelayed(new Runnable() {
//                        @Override
//                        public void run() {
//                            getDataWaiJainEnd("");
//                        }
//                    }, 800);//后执行Runnable中的run方法
//                        getDataReportData();

            //视频接口上传数据
            model.setDetectionItemStartDate(BaseApplication.W_ItemStart_time);
            model.setDetectionItemEndDate(BaseApplication.W_ItemEnd_time);
            model.setDetectionID(String.valueOf(carsInforModel.getID()));

//                        String logStr33 = "\n" + "点击外检完成按钮--333-";
//                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr33.getBytes());
            //让按钮变成不可点击
//                        acWaijianBtnWancheng2.setEnabled(false);

            uploadVideo(model);
        } else {
            Toast.makeText(instances, getResources().getString(R.string.network_error), Toast
                    .LENGTH_LONG).show();
        }

//                finish();
        String logStr22 = "\n" + "点击外检完成按钮--222-";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr22.getBytes());
//                acWaijianBtnWancheng2.setEnabled(false);
    }

    //跳转车管所app,目前只用于哈尔滨地区
    private void gotoApp() {
        UtilsLog.e("stationInforModel==" + stationInforModel.toString());
        String packageName = "com.dongma.takephotos.app";
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setComponent(new ComponentName(packageName, packageName + ".RequestAction"));
        intent.putExtra("jczmc", stationInforModel.getName());//检验机构名称
        intent.putExtra("clsbdh", carsInforModel.getVIN());//车辆识别代号
//        String[] str=carsInforModel.getPlateTypeName().split("-");
        intent.putExtra("hpzl", carsInforModel.getPlateType());//号牌种类
        intent.putExtra("hphm", carsInforModel.getPlateRegion() + carsInforModel.getPlateNO
                ());//车牌号码
        intent.putExtra("jylsh", carsInforModel.getPlatformSN());//查验流水号
        UtilsLog.e("外检-gotoApp-次数==" + carsInforModel.getTimes());
        intent.putExtra("jycs", carsInforModel.getTimes());//次数
        intent.putExtra("jcxdh", Line);//检测线代号
        intent.putExtra("jczbh", stationInforModel.getSecurityNO());//检验机构编号
        intent.putExtra("jyxm", "F1");//检验项目
        intent.putExtra("zpgs", up_json_str);
//        intent.putExtra("jkxlh","7E1D09090306170400158BCF86C988C78BCC8F9B818DE7EAFC98A2C7A49D636E");//接口序列号
        UtilsLog.e("getInterfaceNO==" + stationInforModel.getInterfaceNO());
        intent.putExtra("jkxlh", stationInforModel.getInterfaceNO());
        intent.putExtra("zdbs", CommonUtils.getIMEI(instances));//终端标识
        String logStr4 = "\n" + "外检--哈尔滨地区--gotoApp===" +
                "zpgs==" + up_json_str + "\n" +
                "jczmc==" + stationInforModel.getName() + "\n" + "clsbdh==" + carsInforModel.getVIN() + "\n" +
                "hpzl==" + carsInforModel.getPlateType() + "\n" + "hphm==" + carsInforModel.getPlateRegion() + carsInforModel.getPlateNO() + "\n" +
                "jylsh==" + carsInforModel.getPlatformSN() + "\n" + "jycs==" + carsInforModel.getTimes() + "\n" +
                "jcxdh==" + Line + "\n" + "jczbh==" + stationInforModel.getSecurityNO() + "\n" +
                "jyxm==" + "F1" + "\n" + "jkxlh==" + stationInforModel.getInterfaceNO() + "\n" +
                "zdbs==" + CommonUtils.getIMEI(instances) + "\n";
        UtilsLog.e(logStr4);
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr4.getBytes());
        startActivityForResult(intent, 20);

    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data != null) {
            switch (requestCode) {
                case 500:
                    List<CheckItemModel> list2 = (List<CheckItemModel>) data.getSerializableExtra("waiJianPhoto_buhege_List");
                    List<MyChoiceModel> waiJianPhoto_List = new ArrayList<>();//Code2选择的列表
                    if (list2 != null && list2.size() > 0) {
                        is_500 = true;
                        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                        Item_2Model item_2 = null;
                        for (int i = 0; i < list2.size(); i++) {
                            item_2 = new Item_2Model();
                            item_2.setID(list2.get(i).getID());
                            item_2.setCode1(list2.get(i).getCode1());
                            item_2.setCode2(list2.get(i).getCode2());
                            item_2.setName2(list2.get(i).getName2());
                            item_2.setFlag(list2.get(i).getFlag());
                            Item_2Model_list.add(item_2);
                        }
                        for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                            for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                                    Item_2Model_list.remove(j);
                                }
                            }
                        }

                        for (int i = 0; i < Item_2Model_list.size(); i++) {
                            MyChoiceModel model = new MyChoiceModel();
                            model.setCode2(Item_2Model_list.get(i).getCode2());
                            model.setChecked(true);
                            model.setName2(Item_2Model_list.get(i).getName2());
                            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                            model.setCode_values(Item_2Model_list.get(i).getFlag());
                            waiJianPhoto_List.add(model);
                        }
                        upload_code_str_500 = "";
                        for (int i = 0; i < waiJianPhoto_List.size(); i++) {
                            upload_code_str_500 = upload_code_str_500 + "\"" + waiJianPhoto_List.get(i).getCode_key() + "\""
                                    + ":" + "\"" + waiJianPhoto_List.get(i).getCode_values() + "\"" + ",";
                        }
                        if (upload_code_str_500.length() > 0) {
                            upload_code_str_500 = upload_code_str_500.substring(0, upload_code_str_500.length() - 1);
                        }
                        UtilsLog.e("list2" + list2.toString());
                        String logStrfw = "\n" + "onActivityResult---500---list2" +
                                "\n" + "list2::" + list2.toString() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    } else {
                        UtilsLog.e("list2====nulll==");
                        String logStrfw = "\n" + "onActivityResult---500---list2" +
                                "\n" + "list2====nulll==" + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    }
                    UtilsLog.e("list2====upload_code_str==" + upload_code_str_500);
                    String logStrfw = "\n" + "onActivityResult---500---upload_code_str_500" +
                            "\n" + "upload_code_str::" + upload_code_str_500 + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    break;
                case 404:
                    List<OtherWaiJianPhotoModel> list = new ArrayList<>();
                    list = (List<OtherWaiJianPhotoModel>) data.getSerializableExtra("othet_waijian_photo");
                    if (list != null && list.size() > 0 && typeModelListAdapter != null && typeModelListAdapter.size() > 0) {
                        String logStr3 = "\n" + "外检-其他拍照照片按钮点击--404---" +
                                "onActivityResult" + "\n" +
                                "list:" + list.toString() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr3.getBytes());
                        //去掉可能重复的
//                        for (int i = 0; i < typeModelListAdapter.size(); i++) {
//                            for (int j = 0; j < list.size(); j++) {
//                                if ((list.get(j).getName()).equals(typeModelListAdapter.get(i).getName())) {
//                                    typeModelListAdapter.remove(i);
//                                }
//                            }
//                        }

                        //添加新选择的外检拍照
                        TypeModel typeModel = null;
                        for (int j = 0; j < list.size(); j++) {
                            typeModel = new TypeModel();
                            typeModel.setName(list.get(j).getName());
                            typeModel.setCode(list.get(j).getCode());
                            typeModelListAdapter.add(typeModel);
                        }

                        //重新适配listview
                        contentAdapter2 = new ContentAdapter2(instances, typeModelListAdapter,
                                mListener, instances, 0);
                        acWaijianPhotoListview.setAdapter(contentAdapter2);
                        setListViewHeightBasedONChildren(acWaijianPhotoListview);
//                        Utility.setListViewHeightBasedOnChildren(acWaijianPhotoListview);
//                        acWaijianPhotoListview.setSelection(ListView.FOCUS_DOWN);
                    }

                    if (list != null && list.size() > 0 && typeModelListAdapter.size() == 0) {
                        //添加新选择的外检拍照
                        TypeModel typeModel = null;
                        for (int j = 0; j < list.size(); j++) {
                            typeModel = new TypeModel();
                            typeModel.setName(list.get(j).getName());
                            typeModel.setCode(list.get(j).getCode());
                            typeModelListAdapter.add(typeModel);
                        }
                        //重新适配listview
                        contentAdapter2 = new ContentAdapter2(instances, typeModelListAdapter,
                                mListener, instances, 0);
                        acWaijianPhotoListview.setAdapter(contentAdapter2);
                        setListViewHeightBasedONChildren(acWaijianPhotoListview);
//                        Utility.setListViewHeightBasedOnChildren(acWaijianPhotoListview);
                    }
                    break;
                default:
                    break;
            }
        }
    }


    private void getData(File file, String file_name) {
        if (!TextUtils.isEmpty(SharedPreferencesUtils.getIP(instances))) {
            if (CommonUtils.isOnline(instances)) {
                getDataUploadPhoto(file, file_name);
            } else {
                Toast.makeText(instances, getResources().getString(R.string.network_error), Toast
                        .LENGTH_LONG).show();
            }
        } else {
            Toast.makeText(this, "请设置IP与端口号", Toast.LENGTH_LONG).show();
        }
    }

    //上传照片
    private void getDataUploadPhoto(final File file, final String file_name) {
        String IMEI = "";
        if (!TextUtils.isEmpty(SharedPreferencesUtils.getIMEI(this))) {
            IMEI = SharedPreferencesUtils.getIMEI(this);
        } else {
            String str0 = "", str1 = "";
            str0 = CommonUtils.getIMEI(this, 0);
            str1 = CommonUtils.getIMEI(this, 1);
            if (!TextUtils.isEmpty(str0) && str0 != "") {
                IMEI = str0;
            } else {
                IMEI = str1;
            }
        }
        Log.e("photo", "6666666");
        UtilsLog.e("getDataUploadPhoto---url==" + SharedPreferencesUtils.getFileIP(instances) + UPLOAD_PHOTO);
        String str = "QueueID:" + carsInforModel.getQueueID() + "\n" +
                "GUID:" + carsInforModel.getGUID() + "\n" +
                "Times:" + carsInforModel.getTimes() + "\n" +
                "PlatformSN:" + carsInforModel.getPlatformSN() + "\n" +
                "SN:" + carsInforModel.getSN() + "\n" +
                "PhotoDate:" + DateUtil.currentTime2() + "\n" +
                "PhotoType:" + PHOTO_TYPE + "\n" +
                "Type:" + carsInforModel.getType() + "\n" +
                "CarNO:" + carsInforModel.getPlateRegion() +
                carsInforModel.getPlateNO() + "\n" +
                "PlateType:" + carsInforModel.getPlateType() + "\n" +
                "ItemCode:" + "F1" + "\n" +
                "Line:" + waijian_chedao + "\n" +
                "VIN:" + carsInforModel.getVIN() + "\n" +
                "AppearanceInspector:" + Login_name + "\n" +
                "IMEI:" + IMEI + "\n" +
                "FileType:" + "jpg" + "\n";
        UtilsLog.e("安检getDataUploadPhoto---json==" + str);
        String logStr = "\n" + "安检---外检上传照片---json==" +
                "\n" + "json::" + str + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getFileIP(instances) + UPLOAD_PHOTO).tag(instances)
                .params("AppearanceInspector", Login_name)
                .params("IMEI", IMEI)
                //guid
                .params("QueueID", carsInforModel.getQueueID())
                //guid
                .params("GUID", carsInforModel.getGUID())
                //次数
                .params("Times", carsInforModel.getTimes())
                //PlatformSN
                .params("PlatformSN", carsInforModel.getPlatformSN())
                //SN
                .params("SN", carsInforModel.getSN())
                //拍摄时间
                .params("PhotoDate", DateUtil.currentTime2())
                //照片类型-拍的哪里的照片，位置
//                .params("PhotoType", getPlatformCode(PHOTO_TYPE))
                .params("PhotoType", PHOTO_TYPE)

                //车辆类型
                .params("Type", carsInforModel.getType())
                //车牌号码，两个拼起来的
                .params("CarNO", carNo)
                //号牌类型
                .params("PlateType", carsInforModel.getPlateType())
                //拍照code F1表示外检
                .params("ItemCode", "F1")
                //外检车道，检测线代号
                .params("Line", waijian_chedao)
                //车辆识别代码
                .params("VIN", carsInforModel.getVIN())
                .params("FileType", "jpg")
//                .params("FileType", FileUtils.getExtensionName(file.getName()))
                //照片
                .params("zp", file)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataUploadPhoto-result==" + result);

                        String logStr = "\n" + "外检上传照片--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getFileIP(instances) +
                                UPLOAD_PHOTO + "\n" + "result:" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        UtilsLog.e("response.headers()-result==" + response.headers());
//                        photo_result(PHOTO_TYPE);
//                        if (PHOTO_TYPE != null) {
//                            WAIJIAN_PHOTO_PREVIEW_LISTS.put(Integer.parseInt(PHOTO_TYPE), file);
//                        }
                        WAIJIAN_PHOTO_PREVIEW_LISTS.put(PHOTO_TYPE, file);
                        if (!TextUtils.isEmpty(result) && !"[[]]".equals(result) && !"[{}]".equals(result)
                                && !"[]".equals(result)) {
                            String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\",
                                    "");
                            UtilsLog.e("getDataUploadPhoto-newResult==" + newResult);
                            if ("ok".equalsIgnoreCase(newResult)) {
//                                try {
//                                    if (!TextUtils.isEmpty(file_name)) {
//                                        CommonUtils.DeleteImage(instances, file_name);
//                                        String[] str_photo_path = file_name.split("Pictures");
//
//                                        UtilsLog.e("str_photo_path[0]===" + str_photo_path[0]);
//                                        UtilsLog.e("str_photo_path[1]===" + str_photo_path[1]);
//                                        com.mvd.app.commons.FileUtils.deleteDirectory(Environment
//                                                .getExternalStorageDirectory() + "/Pictures" +
//                                                str_photo_path[1]);
//                                    } else {
//                                        String logStr2 = "\n" + "外检上传照片--没有获取到即将删除的图片路径" + "\n";
//                                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE,
//                                                logStr2.getBytes());
//                                        UtilsLog.e("getDataUploadPhoto==没有获取到即将删除的图片路径");
//                                    }
//                                } catch (Exception e) {
//                                    e.printStackTrace();
//                                }

                                Toast.makeText(instances, "上传成功", Toast.LENGTH_LONG).show();
                                typeModel.setColor(1);
                                typeModelListAdapter.set(TypeModel_Position, typeModel);
                                contentAdapter2.notifyDataSetChanged();
                            } else {
                                String logStr2 = "\n" + "外检上传照片--失败" +
                                        "\n" + "URL::" + SharedPreferencesUtils.getFileIP(instances) +
                                        UPLOAD_PHOTO + "\n" + "result:" + response.body();
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                Toast.makeText(instances, "上传失败，请重新拍照", Toast.LENGTH_LONG).show();
                            }
                        } else {
                            String logStr3 = "\n" + "外检上传照片--失败" +
                                    "\n" + "data::" + "没有数据" + "\n" + "result:" + response.body();
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr3.getBytes());
                            UtilsLog.e("getDataUploadPhoto-result==" + "没有数据");
                        }
                        CommonUtils.hideLoadingDialog(instances);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataUploadPhoto-onError==" + response.body());
                        UtilsLog.e("getDataUploadPhoto-onError==" + response.getException());
                        String logStr = "\n" + "外检上传照片-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getFileIP(instances) +
                                UPLOAD_PHOTO + "\n" + "result:" + response.body() + "\n" +
                                response.getException() + "\n" + response.message();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);

                        Toast.makeText(instances, "上传照片失败，请重试", Toast.LENGTH_LONG).show();
                    }
                });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        OkGo.getInstance().cancelTag(this);
        instances = null;
        String logStrf = "\n" + "onDestroy-----外检拍照---WaiJianPhotoActivity-----" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
        mCvCountupViewTest1.stop();
        List<WaiJianItemModel> books = WaiJianItemModel.listAll(WaiJianItemModel.class);
        if (books != null && books.size() > 0) {
            for (int i = 0; i < books.size(); i++) {
                WaiJianItemModel.delete(books.get(i));
            }
        }
    }

    //外检检测结束
    String getDataWaiJainEnd_upjson_url;

    private void getDataWaiJainEnd(String endTime) {
        CarItemEndModel carItemStartModel = new CarItemEndModel();
        carItemStartModel.setPlatformSN(carsInforModel.getPlatformSN());
        carItemStartModel.setPlateType(carsInforModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
        carItemStartModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        carItemStartModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
        carItemStartModel.setVIN(carsInforModel.getVIN());
        carItemStartModel.setLine(Line);
        carItemStartModel.setTest_times(carsInforModel.getTimes());
        carItemStartModel.setDetectionDevID(SharedPreferencesUtils.getIMEI(instances));
        carItemStartModel.setItemCode(Item_Code);
        BaseApplication.W_ItemEnd_time = "";
        BaseApplication.W_ItemEnd_time = DateUtil.currentTime2();
        my_item_end_time = BaseApplication.W_ItemEnd_time;
        carItemStartModel.setDetectionItemEndDate(BaseApplication.W_ItemEnd_time);
//        carItemStartModel.setDetectionItemEndDate(endTime);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(carItemStartModel);
//        String upjson_url = "{[" + jsonStr.substring(1, jsonStr.length() - 1) + "]}";
        getDataWaiJainEnd_upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";

        String logStr = "\n" + "外检项目结束--json" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(instances) + "" +
                ITEM_END + "\n" + "JSON::" + getDataWaiJainEnd_upjson_url + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getDataWaiJainEnd---jsonStr==" + getDataWaiJainEnd_upjson_url);
        UtilsLog.e("getDataWaiJainEnd---url==" + SharedPreferencesUtils.getIP(this) + ITEM_END);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + ITEM_END).tag(this)
                .upJson(getDataWaiJainEnd_upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataWaiJainEnd-result==" + result);
//                        CommonUtils.hideLoadingDialog(instances);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("getDataWaiJainEnd-newResult==" + newResult);
                        String logStr = "\n" + "外检项目结束--请求成功" + "\n" + "URL::" +
                                SharedPreferencesUtils.getIP(instances) + "" +
                                ITEM_END + "\n" + "JSON::" + getDataWaiJainEnd_upjson_url +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(newResult) || newResult.contains("ok")) {

                            getDataReportData();
                            Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    getDataReportData2();
                                }
                            }, 500);//后执行Runnable中的run方法
                            //新国标升级上传本地后台数据
                            initJsonDataToPlateform(BaseApplication.W_ItemEnd_time);


//                            Toast.makeText(instances, "外检项目完成", Toast
//                                    .LENGTH_LONG).show();
//                            EndAllItem(String.valueOf(carsInforModel.getID()));
                            updateCarStatusInfor(1);
                            acWaijianBtnWancheng2.setEnabled(true);
                            Handler handler22 = new Handler();
                            handler22.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    //项目总结束
//                                updateCarStatusInfor(1);
                                    EndAllItem(String.valueOf(carsInforModel.getID()));
                                }
                            }, 1100);//后执行Runnable中的run方法

//                        if ("ok".equalsIgnoreCase(newResult)) {
//                            Toast.makeText(instances, "外检项目完成", Toast
//                                    .LENGTH_LONG).show();
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    //项目总结束
//                                    updateCarStatusInfor(1);
//                                    EndAllItem(String.valueOf(carsInforModel.getID()));
//                                }
//                            }, 300);//后执行Runnable中的run方法
                        }
//                        else if (carsInforModel.getDetectionCategory().equals("99")) {
//                            getDataReportData();
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    getDataReportData2();
//                                }
//                            }, 500);//后执行Runnable中的run方法
//                            //新国标升级上传本地后台数据
//                            initJsonDataToPlateform(BaseApplication.W_ItemEnd_time);
////                            Toast.makeText(instances, "外检项目完成", Toast
////                                    .LENGTH_LONG).show();
////                            EndAllItem(String.valueOf(carsInforModel.getID()));
//                            updateCarStatusInfor(1);
//                            acWaijianBtnWancheng2.setEnabled(true);
//                            Handler handler22 = new Handler();
//                            handler22.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    //项目总结束
////                                updateCarStatusInfor(1);
//                                    EndAllItem(String.valueOf(carsInforModel.getID()));
//                                }
//                            }, 1100);//后执行Runnable中的run方法
//
//                        }
                        else {
                            CommonUtils.hideLoadingDialog(instances);
//                            MessageDialog.show(instances, "提示", "联网项目开始失败，请重试", "确定");
//                            showDialog("外检平台下线失败，请尝试重新下线");
                            showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataWaiJainEnd-onError==" + response.body());
                        String logStr = "\n" + "外检项目结束-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                ITEM_END + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                        showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    //外检上传平台数据
    String upjson_url;

    private void uploadPlatformData_w(String jsonStr) {
        String logStrf2 = "\n" + "--WaiJianPhotoActivity--uploadPlatformData_w-----外检拍照----" + "\n" + "ElectronicHandbrake::" + carsInforModel.getElectronicHandbrake() + "----" + dzss + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf2.getBytes());
        UtilsLog.e("myChoiceModelList_waijian=========uploadPlatformData_w========" + myChoiceModelList_waijian.toString());
        UtilsLog.e("uploadPlatformData_w-------is_db_data===" + is_db_data + "-----" + dzss);
//        Gson gson = new Gson();
//        String jsonStr = gson.toJson(waiJainDataModel);
//        upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," + appendCode2AndValues
//                ()  + "}]";
//        if (SharedPreferencesUtils.getCode2List(instances)) {
        if (is_500) {
            upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," + upload_code_str_500 + "," + dbModelData(false, true) + "}]";
        } else {
            upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," + upload_code_str + "," + dbModelData(false, true) + "}]";
        }
//        } else {
//            upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," + appendCode2AndValues
//                    () + "," + dbModelData(false, true) + "}]";
//        }
        UtilsLog.e("jsonStr.substring(1, jsonStr.length() - 1)=====" + jsonStr.substring(1, jsonStr.length() - 1));
//        UtilsLog.e("dbModelData(false, true)=====" + dbModelData(false, true));
        String logStr = "\n" + "外检上传平台数据--uploadPlatformData_w----json" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(instances) + "" +
                PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url + "\n" + "situation::" + situation + "-----" + dzss;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("uploadPlatformData_w---jsonStr==" + upjson_url);
        UtilsLog.e("uploadPlatformData_w---url==" + SharedPreferencesUtils.getIP(this) + PLAT_FORM_DATA);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + PLAT_FORM_DATA).tag(this)
                .upJson(upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(WaiJianPhotoActivity.this, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("uploadPlatformData_w-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("uploadPlatformData_w-newResult==" + newResult);
                        String logStr = "\n" + "外检上传平台数据--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(newResult)) {
                            //默认不进入--不合格项目--上传的数据；进入不合格项目则不调用
                            if (is_500 == false) {
                                uploadDataByWaiJianItem();
                            }
                            Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    getDataWaiJainEnd("");
                                }
                            }, 800);//后执行Runnable中的run方法
                        } else {
                            CommonUtils.hideLoadingDialog(instances);
                            Intent i = new Intent(instances, ErrorMsgActivity.class);
                            i.putExtra("error_msg", result);
                            startActivity(i);
//                            Intent intent=new Intent(WaiJianPhotoActivity.this,
//                                    MsgActivity.class);
//                            intent.putExtra("w_msg",result);
//                            startActivity(intent);

//                            if (gotoTakePhotoCounts3 < 5) {
//                                String logStr2 = "\n" + "外检上传平台次数=循环=" +
//                                        "\n" + "第" + gotoTakePhotoCounts3 + "次" + "\n" + "JSON::" +
//                                        upjson_url + "\n" + "result::" + result;
//                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
//                                getGET_ALL_ITEMList();
//                                uploadPlatformData_w(waiJainDataModel);
//                                gotoTakePhotoCounts3++;
//                            } else {
////                                CommonUtils.hideLoadingDialog(instances);
//                                String logStr2 = "\n" + "外检上传自己平台次数=循环5次请求失败--没治了=" +
//                                        "\n" + "JSON::" + upjson_url + "\n" +
//                                        "result::" + result;
//                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
//                                showDialog("上传平台数据失败，请重试，如果还未成功请联系管理员");
//                            }
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("uploadPlatformData_w-onError==" + response.body());
                        String logStr = "\n" + "外检上传平台数据-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                PLAT_FORM_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                        showDialog("上传平台数据失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }


    //组装要上报的json
    private String reportedJsonStr3(String dateType, int flag) {
        String str_json = "";
        if (TextUtils.isEmpty(my_item_start_time) || my_item_start_time.equals("")) {
            my_item_start_time = DateUtil.currentTime2();
        }
        String myjson = "";
        CodeListModel codeListModel = null;
        List<CodeListModel> codeList_list = new ArrayList<>();
        if (BaseApplication.BaseApplication_buHeGeModel3List != null
                && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
            //去重
            Utils.removeDuplicate(BaseApplication.BaseApplication_buHeGeModel3List);
            //set集合保存的是引用不同地址的对象
//            Set<BuHeGeModel3> ts = new HashSet<BuHeGeModel3>();
//            ts.addAll(BaseApplication.BaseApplication_buHeGeModel3List);

//            for (BuHeGeModel3 student : ts) {
//                UtilsLog.e("BaseApplication_buHeGeModel3List=去重数据=" +
//                        BaseApplication.BaseApplication_buHeGeModel3List.toString());
////                System.out.println(student.getId()+"-"+student.getName());
//            }

            //去除  IsCheck==1
//            for (int i = 0; i < BaseApplication.BaseApplication_buHeGeModel3List.size(); i++) {
//                UtilsLog.e("BaseApplication_buHeGeModel3List=原始数据=" +
//                        BaseApplication.BaseApplication_buHeGeModel3List.toString());
//                if ("1".equals(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getIsCheck())) {
//                    BaseApplication.BaseApplication_buHeGeModel3List.remove(i);
//                }
//            }
            str_json = "1111" + "\n";
            if (BaseApplication.BaseApplication_buHeGeModel3List != null
                    && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
                str_json = str_json + "222" + "\n";
                for (int i = 0; i < BaseApplication.BaseApplication_buHeGeModel3List.size(); i++) {
                    UtilsLog.e("BaseApplication_buHeGeModel3List=去掉IsCheck==1后的数据=" +
                            BaseApplication.BaseApplication_buHeGeModel3List.toString());
//                    codeListModel = new CodeListModel();
//                    codeListModel.setDataType(dateType);
//                    codeListModel.setGUID(carsInforModel.getGUID());
//                    if (flag == 1) {
//                        if (is_db_data) {
//                            codeListModel.setF1ResultNote(books.get(0).getF1ResultNote());
//                        } else {
//                            codeListModel.setF1ResultNote("");
//                        }
//                    }
//                    codeListModel.setTimes(carsInforModel.getTimes());
//                    codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
//                    codeListModel.setTest_times(carsInforModel.getTimes());
//                    codeListModel.setStart_Time(my_item_start_time);
//                    codeListModel.setFinish_Time(my_item_end_time);
//                    if ("0".equals(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getIsCheck())) {
//                        codeListModel.setUnqualified_Code1(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode1());
//                        codeListModel.setUnqualified_Code2(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode2());
//                        codeListModel.setUnqualified_Code3(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode3());
//                    }
//                    codeList_list.add(codeListModel);


                    if ("1".equals(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getIsCheck())) {
                        codeListModel = new CodeListModel();
                        if (flag == 1) {
                            if (is_db_data) {
                                codeListModel.setF1ResultNote(books.get(0).getF1ResultNote());
                            } else {
                                codeListModel.setF1ResultNote("");
                            }
                        }else{
//                            if(!TextUtils.isEmpty(jianyi)){
//                                codeListModel.setF1ResultNote(jianyi);
//                            }
                        }
                        UtilsLog.e("reportedJsonStr3333==check===1");
                    } else {
//                        if(!TextUtils.isEmpty(jianyi)){
//                            codeListModel.setF1ResultNote(jianyi);
//                        }
                        UtilsLog.e("reportedJsonStr3333==check===2");
                    }
                    codeListModel.setDataType(dateType);
                    codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
                    codeListModel.setTest_times(carsInforModel.getTimes());
                    codeListModel.setGUID(carsInforModel.getGUID());
                    codeListModel.setTimes(carsInforModel.getTimes());
                    codeListModel.setStart_Time(my_item_start_time);
                    codeListModel.setFinish_Time(my_item_end_time);
                    codeListModel.setUnqualified_Code1(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode1());
                    codeListModel.setUnqualified_Code2(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode2());
                    codeListModel.setUnqualified_Code3(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode3());
                    codeListModel.setMemo(F1_Memo);
                    codeList_list.add(codeListModel);
                }
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                str_json = str_json + myjson + "\n";
                UtilsLog.e("reportedJsonStr3333==BaseApplication.BaseApplication_buHeGeModel3List=有数据=" + myjson);
            } else {
                codeListModel = new CodeListModel();
                codeListModel.setDataType(dateType);
                codeListModel.setGUID(carsInforModel.getGUID());
                codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
                codeListModel.setTest_times(carsInforModel.getTimes());
                codeListModel.setUnqualified_Code1("0");
                codeListModel.setUnqualified_Code2("0");
                codeListModel.setUnqualified_Code3("0");
                codeListModel.setStart_Time(my_item_start_time);
                codeListModel.setFinish_Time(my_item_end_time);
                if (flag == 1) {
                    if (is_db_data) {
                        codeListModel.setF1ResultNote(books.get(0).getF1ResultNote());
                    } else {
                        codeListModel.setF1ResultNote("");
                    }
                }else{
//                    if(!TextUtils.isEmpty(jianyi)){
//                        codeListModel.setF1ResultNote(jianyi);
//                    }
                }
                codeListModel.setTimes(carsInforModel.getTimes());
                codeListModel.setMemo(F1_Memo);
                codeList_list.add(codeListModel);
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                str_json = str_json + myjson + "333" + "\n";
                UtilsLog.e("reportedJsonStr4444==" + myjson);
                UtilsLog.e("reportedJsonStr3333==BaseApplication.BaseApplication_buHeGeModel3List=没有数据=" + myjson);
            }
            UtilsLog.e("reportedJsonStr555==有选择不合格项目====" + myjson);
        } else {
            codeListModel = new CodeListModel();
            codeListModel.setDataType(dateType);
            codeListModel.setGUID(carsInforModel.getGUID());
            codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
            codeListModel.setTest_times(carsInforModel.getTimes());
            codeListModel.setUnqualified_Code1("0");
            codeListModel.setUnqualified_Code2("0");
            codeListModel.setUnqualified_Code3("0");
            codeListModel.setStart_Time(my_item_start_time);
            codeListModel.setFinish_Time(my_item_end_time);
            if (flag == 1) {
                if (is_db_data) {
                    codeListModel.setF1ResultNote(books.get(0).getF1ResultNote());
                } else {
                    codeListModel.setF1ResultNote("");
                }
            }else{
//                if(!TextUtils.isEmpty(jianyi)){
//                    codeListModel.setF1ResultNote(jianyi);
//                }
            }
            codeListModel.setTimes(carsInforModel.getTimes());
            codeListModel.setMemo(F1_Memo);
            codeList_list.add(codeListModel);
            Gson gson = new Gson();
            String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
            myjson = jsonStr;
            str_json = str_json + myjson + "444" + "\n";
            UtilsLog.e("reportedJsonStr555==没有选择不合格项目====" + myjson);
        }
        String logStr = "\n" + "外检上传自己后台数据--reportedJsonStr3----" + "\n"
                + "dateType::" + dateType +
                "\n" + "JSON::" + str_json + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        return myjson;
    }

    String myjson;

    private void getDataReportData() {
        UtilsLog.e("getDataReportData---url==" + SharedPreferencesUtils.getIP(instances) + REPORTED_DATA);
//        myjson = reportedJsonStr();
        myjson = reportedJsonStr3("F1", 0);
        String logStr = "\n" + "上传本地数据--getDataReportData--F1--json" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(instances) + "" +
                REPORTED_DATA + "\n" + "JSON::" + myjson + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getDataReportData-result=myjson=" + myjson);
        OkGo.<String>post(SharedPreferencesUtils.getIP(instances) + REPORTED_DATA).tag(instances)
                .upJson(myjson)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataReportData-result==" + result);
                        String logStr = "\n" + "外检上传自己后台数据--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                REPORTED_DATA + "\n" + "JSON::" + myjson +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(instances);
                        if ("\"ok\"".equals(result)) {

                        } else {
                            if (gotoTakePhotoCounts < 5) {
                                String logStr2 = "\n" + "外检上传自己后台次数=循环=" +
                                        "\n" + "第" + gotoTakePhotoCounts + "次" + "\n" + "JSON::" +
                                        myjson + "\n" + "result::" + result;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                getDataReportData();
                                gotoTakePhotoCounts++;
                            } else {
                                CommonUtils.hideLoadingDialog(instances);
                                String logStr2 = "\n" + "外检上传自己后台次数=循环5次请求失败--没治了=" +
                                        "\n" + "JSON::" + myjson + "\n" +
                                        "result::" + result;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                            }
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataReportData-onError==" + response.body());
                        UtilsLog.e("getDataReportData-onError==" + response.getException());
                        String logStr = "\n" + "外检上传自己后台数据-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                REPORTED_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
//                        Toast.makeText(instances, getResources().getString(R.string.services_error), Toast
//                                .LENGTH_LONG).show();
                        showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    String myjson2;

    private void getDataReportData2() {
        UtilsLog.e("getDataReportData2---url==" + SharedPreferencesUtils.getIP(instances) + REPORTED_DATA);
        String jsonstr = reportedJsonStr3("F1_Memo", 1);
        myjson2 = "[{" + jsonstr.substring(2, jsonstr.length() - 2) + "," +
                dbModelData(true, false) + "}]";
        UtilsLog.e("getDataReportData2-result=myjson=" + myjson2);
        String logStr = "\n" + "上传本地数据--getDataReportData2--F1_Memo--json" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(instances) + "" +
                REPORTED_DATA + "\n" + "JSON::" + myjson2 + "\n" + "situation::" + situation;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(instances) + REPORTED_DATA).tag(instances)
                .upJson(myjson2)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataReportData2-result==" + result);
                        String logStr = "\n" + "外检上传自己后台数据--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                REPORTED_DATA + "\n" + "JSON::" + myjson2 +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(instances);
                        if ("\"ok\"".equals(result)) {

                        } else {
                            if (gotoTakePhotoCounts2 < 5) {
                                String logStr2 = "\n" + "外检上传自己后台次数=循环=" +
                                        "\n" + "第" + gotoTakePhotoCounts2 + "次" + "\n" + "JSON::" +
                                        myjson2 + "\n" + "result::" + result;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                getDataReportData2();
                                gotoTakePhotoCounts2++;
                            } else {
                                CommonUtils.hideLoadingDialog(instances);
                                String logStr2 = "\n" + "外检上传自己后台次数=循环5次请求失败--没治了=" +
                                        "\n" + "JSON::" + myjson2 + "\n" +
                                        "result::" + result;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
//                                TipDialog.show(instances, "联网项目开始成功", TipDialog.TYPE.WARNING);
//                                MessageDialog.show(instances,  "上传后台数据失败，请重试，如果还未成功请联系管理员", "确定");
                                showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                            }
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataReportData2-onError==" + response.body());
                        UtilsLog.e("getDataReportData2-onError==" + response.getException());
                        String logStr = "\n" + "外检上传自己后台数据-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                REPORTED_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
//                        Toast.makeText(instances, getResources().getString(R.string.services_error), Toast
//                                .LENGTH_LONG).show();
//                        showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    List<MyChoiceModel> myChoiceModelList_waijian = new ArrayList<>();//Code2选择的列表

    //拼装json  --Code2
    private String appendCode2AndValues() {
        String Code2JsonStr = "";
        String result = "";
        if (myChoiceModelList_waijian != null && myChoiceModelList_waijian.size() > 0) {
            for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
//                UtilsLog.e("Code2JsonStr=22=myChoiceModelList==22222222222222=" + myChoiceModelList_waijian.get(i).toString());
                Code2JsonStr = Code2JsonStr + "\"" + myChoiceModelList_waijian.get(i).getCode_key() + "\""
                        + ":" + "\"" + myChoiceModelList_waijian.get(i).getCode_values() + "\"" + ",";
            }
//            UtilsLog.e("Code2JsonStr==" + Code2JsonStr);
//            UtilsLog.e("Code2JsonStr=22=" + Code2JsonStr.substring(0, Code2JsonStr.length() - 1));
        } else {
            showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
            bb();
            UtilsLog.e("Code2JsonStr=22=nullll");
        }
        if (Code2JsonStr.length() > 0) {
            result = Code2JsonStr.substring(0, Code2JsonStr.length() - 1);
        }
//        UtilsLog.e("Code2JsonStr=22=appendCode2AndValues---------------------000000");
        UtilsLog.e("Code2JsonStr=22=appendCode2AndValues-----000000==" + result);
        return result;
    }

    String situation = "";

    String dbModelData(boolean is, boolean f1_resul_tnote) {
        String result = "";
        Gson gson = new Gson();
        WaiJianItemModel model = null;
        WaiJainDataModel waiJainDataModel = null;
        String logStr_TurnAxis = "";
        try {
            logStr_TurnAxis += "\n" + "dbModelData-转向轴数量===" +
                    "\n" + "dzss==" + dzss + "\n" + "转向轴数量::" + carsInforModel.getTurnAxis() + "\n";
        } catch (Exception e) {
            logStr_TurnAxis += e.getMessage();
        }
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr_TurnAxis.getBytes());

        if (Integer.valueOf(carsInforModel.getTimes()) > 1 && carsInforModel != null) {
            //复检
            situation = "数据来源----复检车辆详情数据";
            if (is_db_data) {
                situation += "------本地数据库有数据";
                model = new WaiJianItemModel();
                waiJainDataModel = new WaiJainDataModel();
                model = books.get(0);
                Log.e("tag", "model====" + model);
                waiJainDataModel.setRemark(model.getRemark());
                waiJainDataModel.setOdometer(model.getOther_1());//里程表读数
                //转向轴数量
                waiJainDataModel.setTurnAxis(model.getZhuanxiangzhou());
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
//                waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
//            }
//            //驻车制动是否使用电子控制装置
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getElectronicHandbrake()))) {
//                waiJainDataModel.setElectronicHandbrake(
//                        carsInforModel.getElectronicHandbrake().equals("1") ? "1" : "0");
//            }
//            //空气悬架轴
//            waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//            //是否配备空气悬架
//            waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension().equals("1") ? "1" : "0");

                //驻车制动是否使用电子控制装置
//            if (model.getShifouDianzikongzhi().contains("是")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }
                //电子手刹
//            if (carsInforModel.getElectronicHandbrake().contains("1")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }

//            if (model.getShifouDianzikongzhi() != null) {
                if (model.getShifouDianzikongzhi().contains("是")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
//            }
//            if (dzss.equals("是")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }
                if (model.getKongqiXuanjia().contains("是")) {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
//                if (model.getKongqiXuanjiaZhou() != "") {
//                    waiJainDataModel.setAirSuspensionAxle(model.getKongqiXuanjiaZhou());
//                } else {
//                    waiJainDataModel.setAirSuspensionAxle("0");
//                }
                waiJainDataModel.setAirSuspensionAxle(model.getKongqiXuanjiaZhou());
                if (is) {
                    //是否全时/适时四驱
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    waiJainDataModel.setDriverType(carsInforModel.getDriverType());
//                }
                    waiJainDataModel.setDriverType(model.getShifouQuanshi());
                } else {

                }
                if (model.getShifouQuanshi().equals("是")) {
                    waiJainDataModel.setFourWheelDrive("1");
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
//            TireTreadVerdict 轮胎花纹深度，
//            AxisLeftHeightVerdict 车身对称部位，
//            LiftHeightVerdict 栏板高度
                waiJainDataModel.setTireTreadVerdict(model.getHege_luntai());
                waiJainDataModel.setAxisLeftHeightVerdict(model.getHege_cheshen());
                waiJainDataModel.setLiftHeightVerdict(model.getHege_lanban());
                waiJainDataModel.setWKLength(model.getWaikuoChang());
                waiJainDataModel.setWKWidth(model.getWaikuoKuan());
                waiJainDataModel.setWKHeight(model.getWaikuoGao());
                waiJainDataModel.setDLiftHeight(model.getChexiangLanbanGaodu());
                waiJainDataModel.setTurnTireTreadDepth(model.getDancheZhuanxianglunLuntaiHuawenShendu());
                waiJainDataModel.setOtherTireTreadDepth(model.getDancheQtaLuntaiHuawenShendu());
                waiJainDataModel.setGLiftHeight(model.getGuaCheLanbanGaodu());
                waiJainDataModel.setGTireTreadDepth(model.getGuacheLuntaiHuanwenShendu());
                waiJainDataModel.setFirstAxisLeftHeight(model.getDiyizhouZuogaodu());
                waiJainDataModel.setFirstAxisRightHeight(model.getDiyizhouYougaodu());
                waiJainDataModel.setFirstAxisHeightDiff(model.getDiyizhouZuoyouGaodu());
                waiJainDataModel.setLastAxisLeftHeight(model.getZuihouzhouZuoGaodu());
                waiJainDataModel.setLastAxisRightHeight(model.getZuihouzhouYouGaodu());
                waiJainDataModel.setLastAxisHeightDiff(model.getZuihouzhouZuoyouGaodu());
                waiJainDataModel.setGAxisLeftHeight(model.getGuaCheZuoGaodu());
                waiJainDataModel.setGAxisRightHeight(model.getGuaCheYouGaodu());
                waiJainDataModel.setGAxisHeightDiff(model.getGuaCheGaoduGaoducha());
                waiJainDataModel.setWheelBase(model.getZhouju());
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote(model.getF1ResultNote());
                } else {
                    waiJainDataModel.setF1ResultNote("");
                }
                result = gson.toJson(waiJainDataModel);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result +
                        "dzss::" + dzss;
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            } else {
                situation += "------用车辆本身的数据，本地数据库没有数据";
                waiJainDataModel = new WaiJainDataModel();
                waiJainDataModel.setRemark("");
                //转向轴数量
                waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());

//                waiJainDataModel.setElectronicHandbrake(carsInforModel.getElectronicHandbrake().equals("1") ? "1" : "0");
//                waiJainDataModel.setElectronicHandbrake(carsInforModel.getElectronicHandbrake());
                if (carsInforModel.getElectronicHandbrake().equals("1")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
//                if (dzss.equals("是")) {
//                    waiJainDataModel.setElectronicHandbrake("1");
//                } else {
//                    waiJainDataModel.setElectronicHandbrake("0");
//                }

                if (carsInforModel.getAirSuspension() == "1") {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
                waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//                if (carsInforModel.getAirSuspensionAxle() != "") {
//                    waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//                } else {
//                    waiJainDataModel.setAirSuspensionAxle("0");
//                }
//                waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension());
//                waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());

                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
                    if (carsInforModel.getDriverType().equals("2") ||
                            carsInforModel.getDriverType().equals("3")) {
                        waiJainDataModel.setFourWheelDrive("1");
                    } else {
                        waiJainDataModel.setFourWheelDrive("0");
                    }
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
//            waiJainDataModel.setFourWheelDrive(carsInforModel.getDriverType());
//            TireTreadVerdict 轮胎花纹深度，
//            AxisLeftHeightVerdict 车身对称部位，
//            LiftHeightVerdict 栏板高度
                waiJainDataModel.setTireTreadVerdict(TextUtils.isEmpty(carsInforModel.getTireTreadVerdict()) ? "" : carsInforModel.getTireTreadVerdict());
                waiJainDataModel.setAxisLeftHeightVerdict(TextUtils.isEmpty(carsInforModel.getAxisLeftHeightVerdict()) ? "" : carsInforModel.getAxisLeftHeightVerdict());
                waiJainDataModel.setLiftHeightVerdict(TextUtils.isEmpty(carsInforModel.getLiftHeightVerdict()) ? "" : carsInforModel.getLiftHeightVerdict());
                waiJainDataModel.setWKLength(TextUtils.isEmpty(carsInforModel.getWKLength()) ? "" : carsInforModel.getWKLength());
                waiJainDataModel.setWKWidth(TextUtils.isEmpty(carsInforModel.getWKWidth()) ? "" : carsInforModel.getWKWidth());
                waiJainDataModel.setWKHeight(TextUtils.isEmpty(carsInforModel.getWKHeight()) ? "" : carsInforModel.getWKHeight());
                waiJainDataModel.setDLiftHeight(TextUtils.isEmpty(carsInforModel.getDLiftHeight()) ? "" : carsInforModel.getDLiftHeight());
                waiJainDataModel.setTurnTireTreadDepth(TextUtils.isEmpty(carsInforModel.getTurnTireTreadDepth()) ? "" : carsInforModel.getTurnTireTreadDepth());
                waiJainDataModel.setOtherTireTreadDepth(TextUtils.isEmpty(carsInforModel.getOtherTireTreadDepth()) ? "" : carsInforModel.getOtherTireTreadDepth());
                waiJainDataModel.setGLiftHeight(TextUtils.isEmpty(carsInforModel.getGLiftHeight()) ? "" : carsInforModel.getGLiftHeight());
                waiJainDataModel.setGTireTreadDepth(TextUtils.isEmpty(carsInforModel.getGTireTreadDepth()) ? "" : carsInforModel.getGTireTreadDepth());
                waiJainDataModel.setFirstAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getFirstAxisLeftHeight()) ? "" : carsInforModel.getFirstAxisLeftHeight());
                waiJainDataModel.setFirstAxisRightHeight(TextUtils.isEmpty(carsInforModel.getFirstAxisRightHeight()) ? "" : carsInforModel.getFirstAxisRightHeight());
                waiJainDataModel.setFirstAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getFirstAxisHeightDiff()) ? "" : carsInforModel.getFirstAxisHeightDiff());
                waiJainDataModel.setLastAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getLastAxisLeftHeight()) ? "" : carsInforModel.getLastAxisLeftHeight());
                waiJainDataModel.setLastAxisRightHeight(TextUtils.isEmpty(carsInforModel.getLastAxisRightHeight()) ? "" : carsInforModel.getLastAxisRightHeight());
                waiJainDataModel.setLastAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getLastAxisHeightDiff()) ? "" : carsInforModel.getLastAxisHeightDiff());
                waiJainDataModel.setGAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getGAxisLeftHeight()) ? "" : carsInforModel.getGAxisLeftHeight());
                waiJainDataModel.setGAxisRightHeight(TextUtils.isEmpty(carsInforModel.getGAxisRightHeight()) ? "" : carsInforModel.getGAxisRightHeight());
                waiJainDataModel.setGAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getGAxisHeightDiff()) ? "" : carsInforModel.getGAxisHeightDiff());
//                waiJainDataModel.setWheelBase(TextUtils.isEmpty(carsInforModel.getWheelBase()) ? "" : carsInforModel.getWheelBase());
                waiJainDataModel.setWheelBase("");
                if (f1_resul_tnote) {
//                    waiJainDataModel.setF1ResultNote(jianyi);
                    waiJainDataModel.setF1ResultNote("");
                } else {

                }
                result = gson.toJson(waiJainDataModel);
                Log.e("tag", "数据来源为复检数据，result==22222222222==" + result + "=====" + dzss);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result +
                        "dzss::" + dzss+ "\n" ;
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            }

        } else {
            if (is_db_data) {
                situation = "初检---数据来源----本地数据库";
                Log.e("tag", situation + "====111111111===" + dzss);
                model = new WaiJianItemModel();
                waiJainDataModel = new WaiJainDataModel();
                model = books.get(0);
                Log.e("tag", "model====" + model);
                waiJainDataModel.setRemark(model.getRemark());
                waiJainDataModel.setOdometer(model.getOther_1());//里程表读数
                //转向轴数量
                waiJainDataModel.setTurnAxis(model.getZhuanxiangzhou());
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
//                waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
//            }
//            //驻车制动是否使用电子控制装置
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getElectronicHandbrake()))) {
//                waiJainDataModel.setElectronicHandbrake(
//                        carsInforModel.getElectronicHandbrake().equals("1") ? "1" : "0");
//            }
//            //空气悬架轴
//            waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//            //是否配备空气悬架
//            waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension().equals("1") ? "1" : "0");

                //驻车制动是否使用电子控制装置
//            if (model.getShifouDianzikongzhi().contains("是")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }
                //电子手刹
//            if (carsInforModel.getElectronicHandbrake().contains("1")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }

//            if (model.getShifouDianzikongzhi() != null) {
                if (model.getShifouDianzikongzhi().contains("是")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
//            }
//            if (dzss.equals("是")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }
                if (model.getKongqiXuanjia().contains("是")) {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
                waiJainDataModel.setAirSuspensionAxle(model.getKongqiXuanjiaZhou());
                if (is) {
                    //是否全时/适时四驱
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    waiJainDataModel.setDriverType(carsInforModel.getDriverType());
//                }
                    waiJainDataModel.setDriverType(model.getShifouQuanshi());
                } else {

                }
                if (model.getShifouQuanshi().equals("是")) {
                    waiJainDataModel.setFourWheelDrive("1");
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
//            TireTreadVerdict 轮胎花纹深度，
//            AxisLeftHeightVerdict 车身对称部位，
//            LiftHeightVerdict 栏板高度
                waiJainDataModel.setTireTreadVerdict(model.getHege_luntai());
                waiJainDataModel.setAxisLeftHeightVerdict(model.getHege_cheshen());
                waiJainDataModel.setLiftHeightVerdict(model.getHege_lanban());
                waiJainDataModel.setWKLength(model.getWaikuoChang());
                waiJainDataModel.setWKWidth(model.getWaikuoKuan());
                waiJainDataModel.setWKHeight(model.getWaikuoGao());
                waiJainDataModel.setDLiftHeight(model.getChexiangLanbanGaodu());
                waiJainDataModel.setTurnTireTreadDepth(model.getDancheZhuanxianglunLuntaiHuawenShendu());
                waiJainDataModel.setOtherTireTreadDepth(model.getDancheQtaLuntaiHuawenShendu());
                waiJainDataModel.setGLiftHeight(model.getGuaCheLanbanGaodu());
                waiJainDataModel.setGTireTreadDepth(model.getGuacheLuntaiHuanwenShendu());
                waiJainDataModel.setFirstAxisLeftHeight(model.getDiyizhouZuogaodu());
                waiJainDataModel.setFirstAxisRightHeight(model.getDiyizhouYougaodu());
                waiJainDataModel.setFirstAxisHeightDiff(model.getDiyizhouZuoyouGaodu());
                waiJainDataModel.setLastAxisLeftHeight(model.getZuihouzhouZuoGaodu());
                waiJainDataModel.setLastAxisRightHeight(model.getZuihouzhouYouGaodu());
                waiJainDataModel.setLastAxisHeightDiff(model.getZuihouzhouZuoyouGaodu());
                waiJainDataModel.setGAxisLeftHeight(model.getGuaCheZuoGaodu());
                waiJainDataModel.setGAxisRightHeight(model.getGuaCheYouGaodu());
                waiJainDataModel.setGAxisHeightDiff(model.getGuaCheGaoduGaoducha());
                waiJainDataModel.setWheelBase(model.getZhouju());
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote(model.getF1ResultNote());
                } else {

                }
                result = gson.toJson(waiJainDataModel);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result +
                        "dzss::" + dzss;
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            } else {
                situation = "初检---数据来源----默认数据---------33333333333333--------";
                Log.e("tag", situation + dzss);
                waiJainDataModel = new WaiJainDataModel();
                waiJainDataModel.setRemark("");
                waiJainDataModel.setOdometer(!TextUtils.isEmpty(carsInforModel.getOdometer()) ? carsInforModel.getOdometer() : "");//里程表读数
                //转向轴数量
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
                    waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
                } else {
                    waiJainDataModel.setTurnAxis("1");
                }
//            waiJainDataModel.setTurnAxis("0");
//            //驻车制动是否使用电子控制装置
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getElectronicHandbrake()))) {
//                waiJainDataModel.setElectronicHandbrake(
//                        carsInforModel.getElectronicHandbrake().equals("1") ? "1" : "0");
//            }
//            //空气悬架轴
//            waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//            //是否配备空气悬架
//            waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension().equals("1") ? "1" : "0");


//                waiJainDataModel.setElectronicHandbrake(carsInforModel.getElectronicHandbrake());
                if (carsInforModel.getElectronicHandbrake().equals("1")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
//                if (carsInforModel.getElectronicHandbrake().equals("是")) {
//                    waiJainDataModel.setElectronicHandbrake("1");
//                } else {
//                    waiJainDataModel.setElectronicHandbrake("0");
//                }
//            if(){
//            model.getShifouDianzikongzhi() == null ?model.setShifouDianzikongzhi("") : model.getShifouDianzikongzhi();
//            if (model.getShifouDianzikongzhi().contains("是")) {
//                waiJainDataModel.setElectronicHandbrake("1");
//            } else {
//                waiJainDataModel.setElectronicHandbrake("0");
//            }
//            }

//                if (dzss.equals("是")) {
//                    waiJainDataModel.setElectronicHandbrake("1");
//                } else {
//                    waiJainDataModel.setElectronicHandbrake("0");
//                }
                Log.e("tag", "getElectronicHandbrake=====" + waiJainDataModel.getElectronicHandbrake());
//            waiJainDataModel.setElectronicHandbrake(carsInforModel.getElectronicHandbrake());
                //空气悬架轴
//            waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//                waiJainDataModel.setAirSuspensionAxle("");
                //是否配备空气悬架
//            waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension().equals("1") ? "1" : "0");
//                waiJainDataModel.setAirSuspension("0");

                if (carsInforModel.getAirSuspension() == "1") {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
                waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());

                if (is) {
                    //是否全时/适时四驱
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    waiJainDataModel.setDriverType(carsInforModel.getDriverType());
//                }
                    waiJainDataModel.setDriverType("0");
                } else {

                }
                waiJainDataModel.setTireTreadVerdict("合格");
                waiJainDataModel.setAxisLeftHeightVerdict("合格");
                waiJainDataModel.setLiftHeightVerdict("合格");
                waiJainDataModel.setWKLength("");
                waiJainDataModel.setWKWidth("");
                waiJainDataModel.setWKHeight("");
                waiJainDataModel.setDLiftHeight("");
                waiJainDataModel.setTurnTireTreadDepth("");
                waiJainDataModel.setOtherTireTreadDepth("");
                waiJainDataModel.setGLiftHeight("");
                waiJainDataModel.setGTireTreadDepth("");
                waiJainDataModel.setFirstAxisLeftHeight("");
                waiJainDataModel.setFirstAxisRightHeight("");
                waiJainDataModel.setFirstAxisHeightDiff("");
                waiJainDataModel.setLastAxisLeftHeight("");
                waiJainDataModel.setLastAxisRightHeight("");
                waiJainDataModel.setLastAxisHeightDiff("");
                waiJainDataModel.setGAxisLeftHeight("");
                waiJainDataModel.setGAxisRightHeight("");
                waiJainDataModel.setGAxisHeightDiff("");
                waiJainDataModel.setWheelBase("");
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote("");
                } else {

                }
//            waiJainDataModel.setF1ResultNote("");
                //是否全时/适时四驱
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
                    if (carsInforModel.getDriverType().equals("2") ||
                            carsInforModel.getDriverType().equals("3")) {
                        waiJainDataModel.setFourWheelDrive("1");
                    } else {
                        waiJainDataModel.setFourWheelDrive("0");
                    }
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
                result = gson.toJson(waiJainDataModel);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result + "\n" +
                        "dzss::" + dzss;
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            }
        }

        UtilsLog.e("========dbModelData---json====" + result);
//        UtilsLog.e("dbModelData---json=111=" + result.substring(1, result.length() - 1));
        return result.substring(1, result.length() - 1);
    }

    //获取需要检测的人工检验项目接口
    private void getMyCarItems() {
        ItemsModel model = new ItemsModel();
        model.setCarType(carsInforModel.getType());
        model.setDetectCategroy(carsInforModel.getDetectionCategory());
        model.setPassengerNb(carsInforModel.getApprovedLoad());
        model.setPlateType(carsInforModel.getPlateType());
        model.setVehicleID(String.valueOf(carsInforModel.getVehicleID()));

        String registerTime = carsInforModel.getRegisteDate();
        String str = registerTime.substring(6, registerTime.length() - 2).trim();
        String registerdate = DateUtil.getDateTimeFromMillisecond(Long.parseLong(str));
        model.setRegisteDate(registerdate);

        Gson gson = new Gson();
        String json_str = gson.toJson(model);
        UtilsLog.e("getMyCarItems---json_str==" + json_str);

        String url = "";
        url = GET_MY_ITEM_38900;
        UtilsLog.e("getMyCarItems---url==" + SharedPreferencesUtils.getIP(this) + url);

        String logStr = "\n" + "外检--获取需要检测的人工检验项目接口--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                url + "\n" + "JSON::" + json_str + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + url).tag(this)
                .upJson(json_str)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
//                        UtilsLog.e("getMyCarItems-newResult==" + newResult);
                        String logStrf = "\n" + "外检--获取需要检测的人工检验项目接口--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());

                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
                                (newResult) && !"[]".equals(result)) {
                            List<CheckItemModel> DiPanDongTai_checkItemlList = new ArrayList<>();
                            mycar_checkItemlList = new ArrayList<CheckItemModel>();
                            myChoiceModelList_waijian = new ArrayList<>();
                            DiPanDongTai_checkItemlList = JsonUtil.stringToArray(newResult,
                                    CheckItemModel[].class);
                            if (DiPanDongTai_checkItemlList != null && DiPanDongTai_checkItemlList.size() > 0) {
                                //给是否拍照列表赋值，初始化
                                for (int i = 0; i < DiPanDongTai_checkItemlList.size(); i++) {
                                    IsTakePhoto.add(false);
                                }
                                List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                                Item_2Model item_2 = null;
                                for (int i = 0; i < DiPanDongTai_checkItemlList.size(); i++) {
//                                    UtilsLog.e("getMyCarItems-DiPanDongTai_checkItemlList==" +
//                                            DiPanDongTai_checkItemlList.get(i).toString());
//                                    DiPanDongTai_checkItemlList.get(i).getCode1().equals("1") ||
//                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("2") ||
                                    if (DiPanDongTai_checkItemlList.get(i).getCode1().equals("3") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("4") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("5") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("6") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("7")) {
                                        mycar_checkItemlList.add(DiPanDongTai_checkItemlList.get(i));

                                        item_2 = new Item_2Model();
                                        item_2.setID(DiPanDongTai_checkItemlList.get(i).getID());
                                        item_2.setCode1(DiPanDongTai_checkItemlList.get(i).getCode1());
                                        item_2.setCode2(DiPanDongTai_checkItemlList.get(i).getCode2());
                                        item_2.setName2(DiPanDongTai_checkItemlList.get(i).getName2());
                                        item_2.setFlag(DiPanDongTai_checkItemlList.get(i).getFlag());
                                        Item_2Model_list.add(item_2);
                                    }
                                }
//                                UtilsLog.e("Item_2Model_list=22=myChoiceMItem_2Model_listodelList==111111=" + Item_2Model_list.toString());
                                for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                                    for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                        if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k)
                                                .getCode2())) {
                                            Item_2Model_list.remove(j);
                                        }
                                    }
                                }
                                if (Item_2Model_list != null && Item_2Model_list.size() > 0) {
                                    setDataModel(Item_2Model_list);
                                } else {
                                    String logStrfw = "\n" + "外检拍照--获取需要检测的人工检验项目接口--Item_2Model_list==null" + "\n";
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                }
                                for (int i = 0; i < Item_2Model_list.size(); i++) {
                                    MyChoiceModel model = new MyChoiceModel();
                                    model.setCode2(Item_2Model_list.get(i).getCode2());
                                    model.setChecked(true);
                                    model.setName2(Item_2Model_list.get(i).getName2());
                                    model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                                    model.setCode_values(Item_2Model_list.get(i).getFlag());
                                    myChoiceModelList_waijian.add(model);
                                }
                                if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
                                    for (int i = 0; i < myChoiceModelList.size(); i++) {
//                                        UtilsLog.e("Code2JsonStr=22=myChoiceModelList==111111=" + myChoiceModelList.get(i).toString());
                                        String Code2 = myChoiceModelList.get(i).getCode2().toString().trim();
                                        for (int j = 0; j < Item_2Model_list.size(); j++) {
                                            String code2_my = Item_2Model_list.get(j).getCode2().toString()
                                                    .trim();
                                            if (Code2.equals(code2_my)) {
                                                myChoiceModelList.get(i).setCode_values(Item_2Model_list.get(j).getFlag());
                                            }
                                        }
                                    }
                                } else {
                                    UtilsLog.e("myChoiceModelList=================");
                                }

                                if (myChoiceModelList_waijian != null && myChoiceModelList_waijian.size() > 0) {
//                                    for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
//                                        String Code2 = myChoiceModelList_waijian.get(i).getCode2().toString().trim();
//                                        for (int j = 0; j < Item_2Model_list.size(); j++) {
//                                            String code2_my = Item_2Model_list.get(j).getCode2().toString()
//                                                    .trim();
//                                            if (Code2.equals(code2_my)) {
//                                                myChoiceModelList_waijian.get(i).setCode_values(Item_2Model_list.get(j).getFlag());
//                                            }
//                                        }
//                                    }
                                    upload_code_str = "";
                                    for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
                                        upload_code_str = upload_code_str + "\"" + myChoiceModelList_waijian.get(i).getCode_key() + "\""
                                                + ":" + "\"" + myChoiceModelList_waijian.get(i).getCode_values() + "\"" + ",";
                                    }
                                    if (upload_code_str.length() > 0) {
                                        upload_code_str = upload_code_str.substring(0, upload_code_str.length() - 1);
                                    }
                                    String logStrfw = "\n" + "外检--获取需要检测的人工检验项目接口--upload_code_str" +
                                            "\n" + "upload_code_str::" + upload_code_str;
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                    UtilsLog.e("upload_code_str========" + upload_code_str);
                                } else {
                                    UtilsLog.e("myChoiceModelList_waijian=================");
                                }
                            } else {
                                UtilsLog.e("getMyCarItems-Result==没有获取到当前车辆检测到的项目");
                            }

                        } else {
                            UtilsLog.e("getGET_ALL_ITEMList-result==" + "没有数据");
                        }
                        CommonUtils.hideLoadingDialog(instances);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getMyCarItems-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                        String logStrf = "\n" + "外检--获取需要检测的人工检验项目接口--请求失败--error" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }
                });
    }


    //视频接口
    private void uploadVideo(VideoModel model) {
//        BaseApplication.W_ItemStart_time = DateUtil.currentTime2();
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);
        UtilsLog.e("uploadVideo---jsonStr==" + jsonStr);
        UtilsLog.e("uploadVideo---url==" + SharedPreferencesUtils.getIP(this) + VIDEO_ITEM);
        String logStr = "\n" + "外检--uploadVideo--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                VIDEO_ITEM + "\n" + "JSON::" + jsonStr + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + VIDEO_ITEM).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("uploadVideo-result==" + result);
//                        CommonUtils.hideLoadingDialog(instances);
                        String logStrf = "\n" + "外检--uploadVideo--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("uploadPlatformData_w-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                        String logStr = "\n" + "外检--uploadVideo-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                VIDEO_ITEM + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }

    //获取某辆车的外检拍照的项目
    // PlateType,CarType,Usage
    String json_str_getOutPhotoItem;

    private void getOutPhotoItem() {
        OutPhotoItem model = new OutPhotoItem();
        model.setCarType(carsInforModel.getType());
        model.setPlateType(carsInforModel.getPlateType());
        model.setUsage(carsInforModel.getUsage());
        model.setPlatformSN(carsInforModel.getPlatformSN());
        Gson gson = new Gson();
        json_str_getOutPhotoItem = gson.toJson(model);
        UtilsLog.e("getOutPhotoItem---json_str==" + json_str_getOutPhotoItem);
        UtilsLog.e("getOutPhotoItem---url==" + SharedPreferencesUtils.getIP(this) + WAI_JIAN_PHOTO_ITEM);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + WAI_JIAN_PHOTO_ITEM).tag(this)
                .upJson(json_str_getOutPhotoItem)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        BaseApplication.msg = result;
//                        UtilsLog.e("getOutPhotoItem-result==" + result);
                        CommonUtils.hideLoadingDialog(instances);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("getOutPhotoItem-newResult==" + newResult);

                        String logStr = "\n" + "外检--获取某辆车的外检拍照的项目--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                WAI_JIAN_PHOTO_ITEM + "\n" + "JSON::" + json_str_getOutPhotoItem
                                + "\n" + newResult;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());

                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
                                (newResult) && !"[]".equals(result)) {

                            typeModelList = JsonUtil.stringToArray(newResult,
                                    TypeModel[].class);
                            if (typeModelList != null && typeModelList.size() > 0) {
                                TypeModel typeModel = null;
                                for (int i = 0; i < typeModelList.size(); i++) {
                                    typeModel = new TypeModel();
                                    typeModel.setName(typeModelList.get(i).getName());
                                    typeModel.setCode(typeModelList.get(i).getCode());
                                    typeModelListAdapter.add(typeModel);
                                }
                                if (SharedPreferencesUtils.getHaErBinVersion(instances)) {
                                    up_json_str = "";
                                    for (int i = 0; i < typeModelList.size(); i++) {
                                        up_json_str += typeModelList.get(i).getCode() + "|" +
                                                typeModelList.get(i).getName() + ",";
                                    }
                                    UtilsLog.e("up_json_str==" + up_json_str.substring(0, up_json_str.length() - 1));
                                    String logStr2 = "\n" + "外检--哈尔滨跳转拼装json===" +
                                            "\n" + "up_json_str::" + up_json_str.substring(0, up_json_str.length() - 1) + "\n" + "up_json_str::" + up_json_str + "\n";
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                }


//                                acWaijianPhotoListview.setSelection(ListView.FOCUS_DOWN);
                                contentAdapter2 = new ContentAdapter2(instances, typeModelListAdapter,
                                        mListener, instances, 0);
                                //实例化ContentAdapter2类，并传入实现类
                                acWaijianPhotoListview.setAdapter(contentAdapter2);
//                                Utility.setListViewHeightBasedOnChildren(acWaijianPhotoListview);
//                                acWaijianPhotoListview.setSelection(ListView.FOCUS_DOWN);
                                setListViewHeightBasedONChildren(acWaijianPhotoListview);
//                                acWaijianPhotoListview.setOnItemClickListener(instances);
                            }
                        } else {
                            String logStr2 = "\n" + "外检--获取某辆车的外检拍照的项目--失败" +
                                    "\n" + "result::" + result;
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());

                            BaseApplication.msg = result;
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        BaseApplication.msg = response.body() + "==" + response.message();
                        UtilsLog.e("getOutPhotoItem-onError==" + response.body());
                        String logStr = "\n" + "外检--获取某辆车的外检拍照的项目-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                WAI_JIAN_PHOTO_ITEM + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    /**
     * 项目总结束接口,最后一个执行
     */
    private void EndAllItem(final String detectionID) {
        UtilsLog.e("EndAllItem---url==" + SharedPreferencesUtils.getIP(instances) + ITEM_ALL_END +
                detectionID + "/DetectionID");
        OkGo.<String>get(SharedPreferencesUtils.getIP(instances) + ITEM_ALL_END +
                detectionID + "/DetectionID").tag(instances)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        //完成按钮可点击
//                        acWaijianBtnWancheng2.setEnabled(true);

                        CommonUtils.hideLoadingDialog(instances);
                        String result = response.body();
                        UtilsLog.e("EndAllItem-result==" + result);
                        String logStr = "\n" + "外检项目总结束:总结束:总结束--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                ITEM_ALL_END + detectionID + "/DetectionID" +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        Toast.makeText(instances, "外检项目完成", Toast
                                .LENGTH_LONG).show();
                        finish();

//                        if ("\"ok\"".equals(result)) {
//
//                            updateCarStatusInfor(1);
//                            Toast.makeText(instances, "外检项目完成", Toast
//                                    .LENGTH_LONG).show();
//
//                        } else {
//                            showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
//                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr = "\n" + "外检项目总结束:总结束:总结束-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                ITEM_ALL_END + detectionID + "/DetectionID" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        UtilsLog.e("EndAllItem-onError==" + response.body());
                        UtilsLog.e("EndAllItem-onError==" + response.getException());
                        CommonUtils.hideLoadingDialog(instances);
                        showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    public static void setListViewHeightBasedONChildren(ListView listView) {
        ListAdapter listAdapter = listView.getAdapter();
        if (listAdapter == null) {
            return;
        }
        int totalHeight = 0;
        for (int i = 0; i < listAdapter.getCount(); i++) {
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();
        }
        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight + 3 * (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        listView.setLayoutParams(params);
    }


    private List<TypeModel> typeModelList;
    private List<TypeModel> typeModelListAdapter;
    private ContentAdapter2 contentAdapter2;

    private void init() {
        typeModelList = new ArrayList<>();
        typeModelListAdapter = new ArrayList<>();
    }

    //响应item点击事件
    @Override
    public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
//        Toast.makeText(this, "listview的item被点击了！，点击的位置是-->" + position,
//                Toast.LENGTH_SHORT).show();
    }

    /**
     * 实现类，响应按钮点击事件
     */
    TypeModel typeModel;
    int TypeModel_Position = 0;
    private String img_imageUri_path;
    private ContentAdapter2.MyClickListener mListener = new ContentAdapter2.MyClickListener() {
        @Override
        public void myOnClick(int position, View v, int flag) {
            PHOTO_TYPE = typeModelListAdapter.get(position).getCode();
            TypeModel_Position = position;
            FLAG = flag;
            if (flag == 0) {
//                //跳转到图片预览界面
//                if (WAIJIAN_PHOTO_PREVIEW_LISTS.get(Integer.parseInt(PHOTO_TYPE)) != null) {
//                    Intent intent_preview = new Intent(instances, PhotoPreviewActivity.class);
//                    intent_preview.putExtra("key_integer", Integer.parseInt(PHOTO_TYPE));
//                    startActivity(intent_preview);
//                }

                //相册
                takePhoto = getTakePhoto();
                File file = new File(Environment.getExternalStorageDirectory(), external_path + "/temp_my_app/" + System
                        .currentTimeMillis() + ".jpg");
                if (!file.getParentFile().exists()) {
                    file.getParentFile().mkdirs();
                }
                imageUri = Uri.fromFile(file);
                UtilsLog.e("photo", "WAIJIAN_PHOTO_imageUri=7777=" + imageUri);
                img_imageUri_path = imageUri.getPath();
                UtilsLog.e("photo", "WAIJIAN_PHOTO_imageUri=888=" + imageUri.getPath());
                takePhoto.onPickFromDocuments();
                typeModel = new TypeModel();
                typeModel.setName(typeModelListAdapter.get(position).getName());
                typeModel.setCode(typeModelListAdapter.get(position).getCode());


            } else if (flag == 1) {
//                takePicture();
//                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//                    takePicture();
//                } else {
                Log.e("photo", "takePhoto---takePhoto");
                takePhoto = getTakePhoto();
                TakePhotoOptions takePhotoOptions = new TakePhotoOptions.Builder().setCorrectImage(false).create();
                takePhoto.setTakePhotoOptions(takePhotoOptions);
//                    configCompress(takePhoto);
//                    File file = new File(Environment.getExternalStorageDirectory(), "/temp_my_app/" + System
//                            .currentTimeMillis() + ".jpg");
                File file = new File(Environment.getExternalStorageDirectory(), external_path + "/temp_my_app/" + System
                        .currentTimeMillis() + ".jpg");
                if (!file.getParentFile().exists()) {
                    file.getParentFile().mkdirs();
                }
                imageUri = Uri.fromFile(file);
                UtilsLog.e("photo", "WAIJIAN_PHOTO_imageUri=7777=" + imageUri);
                img_imageUri_path = imageUri.getPath();
                UtilsLog.e("photo", "WAIJIAN_PHOTO_imageUri=888=" + imageUri.getPath());
                takePhoto.onPickFromCapture(imageUri);
//                }
                typeModel = new TypeModel();
                typeModel.setName(typeModelListAdapter.get(position).getName());
                typeModel.setCode(typeModelListAdapter.get(position).getCode());
            } else if (flag == 2) {
//                //跳转到图片预览界面
                if (WAIJIAN_PHOTO_PREVIEW_LISTS.get(PHOTO_TYPE) != null) {
                    Intent intent_preview = new Intent(instances, PhotoPreviewActivity.class);
                    intent_preview.putExtra("key_integer", PHOTO_TYPE);
                    startActivity(intent_preview);
                }
            }
        }
    };

    /**
     * 更新车辆状态
     *
     * @param flag flag:0 未检测
     * flag:1 项目开始
     * flag:2 项目结束
     * flag:917  中途退出的情况
     */
    String jsonStr22;

    public void updateCarStatusInfor(int flag) {
        UpdateCarStatusModel model = new UpdateCarStatusModel();
        model.setType(0);
        model.setAppearanceInspector(Login_name);
        model.setQueueID(String.valueOf(carsInforModel.getID()));
        switch (CHECK_MODE) {
            case 0:
                model.setAppearanceStatus(flag);
                break;
            case 1:
                model.setRoadStatus(flag);
                break;
            case 2:
                model.setDynamicStatus(flag);
                break;
        }
        Gson gson = new Gson();
        jsonStr22 = gson.toJson(model);
        UtilsLog.e("updateCarStatusInfor---jsonStr==" + jsonStr22);
        UtilsLog.e("updateCarStatusInfor---url==" + SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS)
                .tag(this)
                .upJson(jsonStr22)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("updateCarStatusInfor-result==" + result);
                        UtilsLog.e("updateCarStatusInfor-result=22=" + result.substring(1, result.length() -
                                1));
                        String logStr = "\n" + "外检项目更新状态--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                UPDATE_CAR_STATUS + "\n" + "JSON::" + jsonStr22 + "\n" + "result::" +
                                response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(instances);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataWaiJainStart-onError==" + response.body());
                        String logStr = "\n" + "外检项目更新状态-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                UPDATE_CAR_STATUS + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    //上传本地后台
    private void uploadData(WaiJainDataModel waiJainDataModel) {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(waiJainDataModel);
        UtilsLog.e("外检项目--上传本地后台数据---jsonStr==" + jsonStr);
        UtilsLog.e("外检项目--上传本地后台数据---url==" + SharedPreferencesUtils.getIP(this) + REPORTED_DATA);
        String logStr = "\n" + "外检项目--上传本地后台数据---json" + "\n" +
                "json::" + jsonStr + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + REPORTED_DATA;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + REPORTED_DATA).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("外检项目--上传本地后台数据--result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("外检项目--上传本地后台数据--newResult==" + newResult);
                        String logStr = "\n" + "外检项目--上传本地后台数据---请求成功" +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        if ("ok".equalsIgnoreCase(newResult)) {
////                            Handler handler = new Handler();
////                            handler.postDelayed(new Runnable() {
////                                @Override
////                                public void run() {
////                                    updateCarStatusInfor();
////                                }
////                            }, 800);//后执行Runnable中的run方法
//                        } else {
//                            showDialog("上传本地后台数据失败，请重试");
//                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("外检项目--上传后台数据-onError==" + response.body());
                        String logStr = "\n" + "外检项目--上传本地后台数据--onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                REPORTED_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
//                        showDialog("上传本地后台数据网络异常，请重试");
                    }
                });
    }

    void initJsonDataToPlateform(String finish_time) {
        if (TextUtils.isEmpty(my_item_start_time) || my_item_start_time.equals("")) {
            my_item_start_time = DateUtil.currentTime2();
        }
        waiJainDataModel2.setDetection_ID(String.valueOf(carsInforModel.getID()));
        waiJainDataModel2.setGUID(carsInforModel.getGUID());
        waiJainDataModel2.setDetectionDevID(SharedPreferencesUtils.getIMEI(instances));
        waiJainDataModel2.setBrakeForce(carsInforModel.getBrakeForce());
        waiJainDataModel2.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        waiJainDataModel2.setAirAdmission(carsInforModel.getAirAdmission());
        try {
            String name = URLDecoder.decode(Login_name, "UTF-8");
            waiJainDataModel2.setAppearanceInspector(name);//检测员名字，汉字
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        waiJainDataModel2.setAppearanceNo(login_IDNumber);
        waiJainDataModel2.setApprovedLoad(carsInforModel.getApprovedLoad());
        waiJainDataModel2.setArea(carsInforModel.getArea());
        waiJainDataModel2.setBodyColor(carsInforModel.getBodyColor());
        waiJainDataModel2.setBrand(carsInforModel.getBrand());
        waiJainDataModel2.setCarBodyType(carsInforModel.getCarBodyType());
        waiJainDataModel2.setCarID(carsInforModel.getCarID());
        waiJainDataModel2.setCarModel(carsInforModel.getCarModel());
        waiJainDataModel2.setCarTypeLevel(carsInforModel.getCarTypeLevel());
        waiJainDataModel2.setCategory(carsInforModel.getCategory());
        waiJainDataModel2.setCentralAxle(carsInforModel.getCentralAxle());
        waiJainDataModel2.setCode(carsInforModel.getCode());
        waiJainDataModel2.setCombCarNO(carsInforModel.getCombCarNO());
        waiJainDataModel2.setCurbWeight(carsInforModel.getCurbWeight());
        waiJainDataModel2.setDetectDate(carsInforModel.getDetectDate());
        waiJainDataModel2.setDetectionCategory(carsInforModel.getDetectionCategory());
        waiJainDataModel2.setDetectionStatus(carsInforModel.getDetectionStatus());
        waiJainDataModel2.setDisplacement(carsInforModel.getDisplacement());
        waiJainDataModel2.setDriveAxle(carsInforModel.getDriveAxle());
        waiJainDataModel2.setDriverAxleWeight(carsInforModel.getDriverAxleWeight());
        waiJainDataModel2.setDriverTypeName(carsInforModel.getDriverTypeName());
        waiJainDataModel2.setDriverType(carsInforModel.getDriverType());
        waiJainDataModel2.setPlateType(carsInforModel.getPlateType());
        waiJainDataModel2.setItemcode(Item_Code);
        waiJainDataModel2.setLine(Line);
        waiJainDataModel2.setMainAxis(carsInforModel.getMainAxis());
        waiJainDataModel2.setParkingAxle(carsInforModel.getParkingAxle());
        waiJainDataModel2.setEngineNO(carsInforModel.getEngineNO());
        waiJainDataModel2.setFuelType(carsInforModel.getFuelType());
        waiJainDataModel2.setPlateTypeName(carsInforModel.getPlateTypeName());
        waiJainDataModel2.setPlatformSN(carsInforModel.getPlatformSN());
        waiJainDataModel2.setQueueID(carsInforModel.getQueueID());
        waiJainDataModel2.setSN(carsInforModel.getSN());
        waiJainDataModel2.setStatus(carsInforModel.getStatus());
        waiJainDataModel2.setTest_times(carsInforModel.getTimes());
        waiJainDataModel2.setTimes(carsInforModel.getTimes());
        waiJainDataModel2.setType(carsInforModel.getType());
        waiJainDataModel2.setVIN(carsInforModel.getVIN());
        waiJainDataModel2.setDataType(Item_Code);
        waiJainDataModel2.setOwner(carsInforModel.getOwner());
        waiJainDataModel2.setTelephone(carsInforModel.getTelephone());
        waiJainDataModel2.setAddress(carsInforModel.getAddress());
        waiJainDataModel2.setStart_Time(my_item_start_time);
        waiJainDataModel2.setFinish_Time(finish_time);

//        List<WaiJianItemModel> books = WaiJianItemModel.listAll(WaiJianItemModel.class);
        List<WaiJianItemModel> books = WaiJianItemModel.find(WaiJianItemModel.class, "SN=?", carsInforModel.getSN());

        if (books != null && books.size() > 0) {
            String logStr = "\n" + "initJsonDataToPlateform--查询本地数据库--有数据-" +
                    "\n" + "DB::" + books.toString() + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询--2222--不为空==" + books.toString());
            for (int i = 0; i < books.size(); i++) {
                waiJainDataModel2.setWKLength(books.get(i).getWaikuoChang());
                waiJainDataModel2.setWKHeight(books.get(i).getWaikuoGao());
                waiJainDataModel2.setWKWidth(books.get(i).getWaikuoKuan());
                waiJainDataModel2.setWBase(books.get(i).getZhouju());
                waiJainDataModel2.setTurnTireTreadDepth(books.get(i).getDancheZhuanxianglunLuntaiHuawenShendu());
                waiJainDataModel2.setOtherTireTreadDepth(books.get(i).getDancheQtaLuntaiHuawenShendu());
                waiJainDataModel2.setGTireTreadDepth(books.get(i).getGuacheLuntaiHuanwenShendu());
                waiJainDataModel2.setDLiftHeight(books.get(i).getChexiangLanbanGaodu());
                waiJainDataModel2.setGLiftHeight(books.get(i).getGuaCheLanbanGaodu());
                waiJainDataModel2.setFirstAxisLeftHeight(books.get(i).getDiyizhouZuogaodu());
                waiJainDataModel2.setFirstAxisRightHeight(books.get(i).getDiyizhouYougaodu());
                waiJainDataModel2.setFirstAxisHeightDiff(books.get(i).getDiyizhouZuoyouGaodu());
                waiJainDataModel2.setLastAxisLeftHeight(books.get(i).getZuihouzhouZuoGaodu());
                waiJainDataModel2.setLastAxisRightHeight(books.get(i).getZuihouzhouYouGaodu());
                waiJainDataModel2.setLastAxisHeightDiff(books.get(i).getZuihouzhouZuoyouGaodu());
                waiJainDataModel2.setGAxisLeftHeight(books.get(i).getGuaCheZuoGaodu());
                waiJainDataModel2.setGAxisRightHeight(books.get(i).getGuaCheYouGaodu());
                waiJainDataModel2.setGAxisHeightDiff(books.get(i).getGuaCheGaoduGaoducha());
            }
        } else {
            String logStr = "\n" + "initJsonDataToPlateform--查询本地数据库--null-" +
                    "\n" + "DB::null" + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询--2222--空==");
        }
//        uploadData(waiJainDataModel2);
    }

    /**
     * 获取检测站信息
     */
    private void getStationInfor() {
        UtilsLog.e("getStationInfor---url==" + SharedPreferencesUtils.getIP(instances) + JIAN_CE_ZHAN_INFOR);
        String logStr = "\n" + "获取检测站信息----url" + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + JIAN_CE_ZHAN_INFOR + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>get(SharedPreferencesUtils.getIP(instances) + JIAN_CE_ZHAN_INFOR).tag(instances)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        //完成按钮可点击
//                        CommonUtils.hideLoadingDialog(instances);
                        String result = response.body();
                        String logStr = "\n" + "获取检测站信息----onSuccess" + "\n" +
                                "result::" + result + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        UtilsLog.e("getStationInfor-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
//                        UtilsLog.e("getStationInfor-newResult==" + newResult);

                        String newResult2 = newResult.substring(1, newResult.length() - 1);
//                        UtilsLog.e("getStationInfor-newResult2==" + newResult2);

                        stationInforModel = new StationInforModel();
                        stationInforModel = JsonUtil.fromJson(newResult2, StationInforModel.class);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("EndAllItem-onError==" + response.body());
                        String logStr = "\n" + "获取检测站信息----onError" + "\n" +
                                "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            String logStr = "\n" + "外检--返回键-屏幕底部" + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//            updateCarStatusInfor(ITEM_MIDDLE_EXIT_CODE);
            finish();
            return true;
        } else {
            return super.onKeyDown(keyCode, event);
        }
    }

    AlertDialog.Builder builder = null;

    private void showDialog(String content) {
        AlertDialog.Builder builder = new AlertDialog.Builder
                (instances);
        builder.setTitle("提示");
        builder.setMessage(content);
//        builder.setNegativeButton("取消", null);
        builder.setPositiveButton("确定", null);
        builder.show();
    }

    @Override
    public void onPermissionsGranted(int requestCode, List<String> perms) {
        UtilsLog.e("外检----请求拍照权限成功===");
    }

    @Override
    public void onPermissionsDenied(int requestCode, List<String> perms) {
        UtilsLog.e("外检----请求拍照权限失败===");
    }


    List<WaiJianAddRecordModel> WaiJianAddRecordModelList = new ArrayList<>();//外检增加记录list

    //不进入--不合格项目--默认上传的不合格项目数据
    private void setDataModel(List<Item_2Model> modelList) {
        if (WaiJianAddRecordModelList != null) {
            WaiJianAddRecordModelList.clear();
        }
        WaiJianAddRecordModelList = new ArrayList<>();
        for (int j = 0; j < modelList.size(); j++) {
            WaiJianAddRecordModel model = new WaiJianAddRecordModel();
            model.setDataType("F1_Record");
            model.setDetection_ID(String.valueOf(carsInforModel.getID()));
            model.setGUID(carsInforModel.getGUID());
            model.setTimes(carsInforModel.getTimes());
            model.setUnqualified_Code1(modelList.get(j).getCode1());
            model.setUnqualified_Code2(modelList.get(j).getCode2());
            model.setVerdict(modelList.get(j).getFlag());
            WaiJianAddRecordModelList.add(model);
        }
//        String logStr = "\n" + "外检拍照-增加外检记录接口--setDataModel" +
//                "\n" + "WaiJianAddRecordModelList::" + WaiJianAddRecordModelList.toString() + "\n";
//        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//        UtilsLog.e("外检拍照--setDataModel--WaiJianAddRecordModelList==" + WaiJianAddRecordModelList.toString());
    }

    //外检不合格项目-增加外检记录接口
    private void uploadDataByWaiJianItem() {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(WaiJianAddRecordModelList);
        UtilsLog.e("外检拍照--外检不合格项目---jsonStr==" + jsonStr);
        UtilsLog.e("外检拍照--外检不合格项目---url==" + SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED);
        String logStr = "\n" + "外检拍照--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                WAIJIAN_ADD_RECORED + "\n" + "JSON::" + jsonStr + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("外检拍照--外检不合格项目-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("外检拍照--外检不合格项目-newResult==" + newResult);
//                        CommonUtils.hideLoadingDialog(instances);
//                        if ("ok".equalsIgnoreCase(newResult)) {
//                            Toast.makeText(instances, "提交成功", Toast.LENGTH_LONG).show();
//                            Intent intent = new Intent();
//                            intent.putExtra("waiJianPhoto_buhege_List", (Serializable) mycar_checkItemlList);
//                            instances.setResult(500, intent);
//                            instances.finish();
//                        } else {
//                            Toast.makeText(instances, "提交失败，请重试", Toast
//                                    .LENGTH_LONG).show();
//                        }
                        String logStrf = "\n" + "外检拍照--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("外检拍照--外检不合格项目-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                        String logStr = "\n" + "外检拍照--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem-onError-失败" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }


}
